Ellipse
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System.Collections.Generic;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
public class Ellipse : Curve
{
internal IEllipseEntity EllipseEntity => HostImpl as IEllipseEntity;
public Point CenterPoint => Point.Wrap(EllipseEntity.get_CenterPoint(), true);
public Vector MajorAxis => Vector.Wrap(EllipseEntity.get_MajorAxis(), true);
public Vector MinorAxis => Vector.Wrap(EllipseEntity.get_MinorAxis(), true);
internal Ellipse(IEllipseEntity host, bool persist)
: base(host, persist)
{
}
public override string ToString()
{
return "Ellipse(Normal = " + base.Normal?.ToString() + ", CenterPoint = " + CenterPoint?.ToString() + ", MajorAxis = " + MajorAxis?.ToString() + ", MinorAxis = " + MinorAxis?.ToString() + ")";
}
internal new static void InitType()
{
Geometry.RegisterHostType(typeof(IEllipseEntity), (IGeometryEntity host, bool persist) => new Ellipse(host as IEllipseEntity, persist));
}
internal static Ellipse Wrap(IEllipseEntity host, bool persist = true)
{
if (host == null)
return null;
return new Ellipse(host, persist);
}
internal static Ellipse[] Wrap(IEllipseEntity[] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static Ellipse[][] Wrap(IEllipseEntity[][] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static IEllipseEntity[][] Unwrap(Ellipse[][] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IEllipseEntity[] Unwrap(Ellipse[] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IEllipseEntity[] Unwrap(IEnumerable<Ellipse> o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IEllipseEntity Unwrap(Ellipse o)
{
return o.EllipseEntity;
}
public static Ellipse ByOriginRadii([DefaultArgument("Point.ByCoordinates(0, 0, 0)")] Point origin, [Scaling()] double xAxisRadius = 1, [Scaling()] double yAxisRadius = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
xAxisRadius,
yAxisRadius
});
xAxisRadius /= DesignScriptEntity.scaleFactor;
yAxisRadius /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.EllipseByOriginRadii(Point.Unwrap(origin), xAxisRadius, yAxisRadius), true);
}
public static Ellipse ByOriginVectors([DefaultArgument("Point.ByCoordinates(0, 0, 0)")] Point origin, [DefaultArgument("Vector.ByCoordinates(1, 0, 0)")] Vector xAxisRadius, [DefaultArgument("Vector.ByCoordinates(0, 2, 0)")] Vector yAxisRadius)
{
return Wrap(HostFactory.Factory.EllipseByOriginVectors(Point.Unwrap(origin), Vector.Unwrap(xAxisRadius), Vector.Unwrap(yAxisRadius)), true);
}
public static Ellipse ByCoordinateSystemRadii([DefaultArgument("CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem origin, [Scaling()] double xAxisRadius = 1, [Scaling()] double yAxisRadius = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
xAxisRadius,
yAxisRadius
});
xAxisRadius /= DesignScriptEntity.scaleFactor;
yAxisRadius /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.EllipseByCoordinateSystemRadii(CoordinateSystem.Unwrap(origin), xAxisRadius, yAxisRadius), true);
}
public static Ellipse ByPlaneRadii([DefaultArgument("Plane.XY()")] Plane plane, [Scaling()] double xAxisRadius = 1, [Scaling()] double yAxisRadius = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
xAxisRadius,
yAxisRadius
});
xAxisRadius /= DesignScriptEntity.scaleFactor;
yAxisRadius /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.EllipseByPlaneRadii(Plane.Unwrap(plane), xAxisRadius, yAxisRadius), true);
}
}
}