/*
* Copyright (c) 2023 Codefoco (codefoco@codefoco.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
using System.ComponentModel;
namespace Tizen.NUI.Physics2D.Chipmunk
{
///
/// A circle shape defined by a radius
/// This is the fastest and simplest collision shape
///
[EditorBrowsable(EditorBrowsableState.Never)]
public class Circle : Shape
{
///
/// Create and initialize a circle polygon shape.
///
/// The body to attach the circle to.
/// The radius of the circle.
[EditorBrowsable(EditorBrowsableState.Never)]
public Circle(Body body, double radius)
: this(body, radius, Vect.Zero)
{
}
///
/// Create and initialize an offset circle polygon shape.
///
/// The body to attach the circle to.
/// The radius of the circle.
///
/// The offset from the body's center of gravity in coordinates local to the body.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public Circle(Body body, double radius, Vect offset)
: base(NativeMethods.cpCircleShapeNew(body.Handle, radius, offset))
{
}
///
/// Get the offset of the circle.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public Vect Offset => NativeMethods.cpCircleShapeGetOffset(Handle);
///
/// Get the radius of the circle.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public double Radius => NativeMethods.cpCircleShapeGetRadius(Handle);
///
/// Get the calculated area of the circle.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public new double Area => AreaForCircle(0.0, Radius);
///
/// Calculate the moment of the circle for the given mass.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public double MomentForMass(double mass)
{
return MomentForCircle(mass, Radius, Offset);
}
///
/// Calculate the moment of inertia for the circle.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public static double MomentForCircle(double mass, double innerRadius, double radius, Vect offset)
{
return NativeMethods.cpMomentForCircle(mass, innerRadius, radius, offset);
}
///
/// Calculate the moment of inertia for the circle.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public static double MomentForCircle(double mass, double radius, Vect offset)
{
return NativeMethods.cpMomentForCircle(mass, 0.0, radius, offset);
}
///
/// Calculate the area of a circle or donut.
///
///
/// The radius of the 'donut hole', which defines the area missing.
///
///
/// The outer radius of the donut. This should be greater than the
/// .
///
[EditorBrowsable(EditorBrowsableState.Never)]
public static double AreaForCircle(double innerRadius, double radius)
{
return NativeMethods.cpAreaForCircle(innerRadius, radius);
}
}
}