2 * Copyright (c) 2023 Codefoco (codefoco@codefoco.com)
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 using System.ComponentModel;
25 namespace Tizen.NUI.Physics2D.Chipmunk
28 /// A circle shape defined by a radius
29 /// This is the fastest and simplest collision shape
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public class Circle : Shape
35 /// Create and initialize a circle polygon shape.
37 /// <param name="body">The body to attach the circle to.</param>
38 /// <param name="radius">The radius of the circle.</param>
39 [EditorBrowsable(EditorBrowsableState.Never)]
40 public Circle(Body body, double radius)
41 : this(body, radius, Vect.Zero)
46 /// Create and initialize an offset circle polygon shape.
48 /// <param name="body">The body to attach the circle to.</param>
49 /// <param name="radius">The radius of the circle.</param>
50 /// <param name="offset">
51 /// The offset from the body's center of gravity in coordinates local to the body.
53 [EditorBrowsable(EditorBrowsableState.Never)]
54 public Circle(Body body, double radius, Vect offset)
55 : base(NativeMethods.cpCircleShapeNew(body.Handle, radius, offset))
60 /// Get the offset of the circle.
62 [EditorBrowsable(EditorBrowsableState.Never)]
63 public Vect Offset => NativeMethods.cpCircleShapeGetOffset(Handle);
66 /// Get the radius of the circle.
68 [EditorBrowsable(EditorBrowsableState.Never)]
69 public double Radius => NativeMethods.cpCircleShapeGetRadius(Handle);
72 /// Get the calculated area of the circle.
74 [EditorBrowsable(EditorBrowsableState.Never)]
75 public new double Area => AreaForCircle(0.0, Radius);
78 /// Calculate the moment of the circle for the given mass.
80 [EditorBrowsable(EditorBrowsableState.Never)]
81 public double MomentForMass(double mass)
83 return MomentForCircle(mass, Radius, Offset);
87 /// Calculate the moment of inertia for the circle.
89 [EditorBrowsable(EditorBrowsableState.Never)]
90 public static double MomentForCircle(double mass, double innerRadius, double radius, Vect offset)
92 return NativeMethods.cpMomentForCircle(mass, innerRadius, radius, offset);
96 /// Calculate the moment of inertia for the circle.
98 [EditorBrowsable(EditorBrowsableState.Never)]
99 public static double MomentForCircle(double mass, double radius, Vect offset)
101 return NativeMethods.cpMomentForCircle(mass, 0.0, radius, offset);
105 /// Calculate the area of a circle or donut.
107 /// <param name="innerRadius">
108 /// The radius of the 'donut hole', which defines the area missing.
110 /// <param name="radius">
111 /// The outer radius of the donut. This should be greater than the
112 /// <paramref name="innerRadius"/>.
114 [EditorBrowsable(EditorBrowsableState.Never)]
115 public static double AreaForCircle(double innerRadius, double radius)
117 return NativeMethods.cpAreaForCircle(innerRadius, radius);