Point
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Runtime;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace Autodesk.DesignScript.Geometry
{
public class Point : Geometry
{
internal IPointEntity PointEntity => HostImpl as IPointEntity;
[Scaling()]
public double X {
get {
return PointEntity.get_X() * DesignScriptEntity.scaleFactor;
}
}
[Scaling()]
public double Y {
get {
return PointEntity.get_Y() * DesignScriptEntity.scaleFactor;
}
}
[Scaling()]
public double Z {
get {
return PointEntity.get_Z() * DesignScriptEntity.scaleFactor;
}
}
internal Point(IPointEntity host, bool persist)
: base(host, persist)
{
}
public override string ToString()
{
string[] obj = new string[7] {
"Point(X = ",
null,
null,
null,
null,
null,
null
};
double num = X;
obj[1] = num.ToString(GeometryExtension.DoublePrintFormat, CultureInfo.InvariantCulture);
obj[2] = ", Y = ";
num = Y;
obj[3] = num.ToString(GeometryExtension.DoublePrintFormat, CultureInfo.InvariantCulture);
obj[4] = ", Z = ";
num = Z;
obj[5] = num.ToString(GeometryExtension.DoublePrintFormat, CultureInfo.InvariantCulture);
obj[6] = ")";
return string.Concat(obj);
}
protected override bool Equals(DesignScriptEntity other)
{
if (base.Equals(other))
return true;
Point point = other as Point;
if (point == null)
return false;
double num = point.X;
if (num.Equals(X)) {
num = point.Y;
if (num.Equals(Y)) {
num = point.Z;
return num.Equals(Z);
}
}
return false;
}
protected override int ComputeHashCode()
{
int num = 17;
int num2 = num * 23;
double num3 = X;
num = num2 + num3.GetHashCode();
int num4 = num * 23;
num3 = Y;
num = num4 + num3.GetHashCode();
int num5 = num * 23;
num3 = Z;
return num5 + num3.GetHashCode();
}
internal static void InitType()
{
Geometry.RegisterHostType(typeof(IPointEntity), (IGeometryEntity host, bool persist) => new Point(host as IPointEntity, persist));
}
internal static Point Wrap(IPointEntity host, bool persist = true)
{
if (host == null)
return null;
return new Point(host, persist);
}
internal static Point[] Wrap(IPointEntity[] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static Point[][] Wrap(IPointEntity[][] hosts, bool persist = true)
{
return (from x in hosts
select Wrap(x, persist)).ToArray();
}
internal static IPointEntity[][] Unwrap(Point[][] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IPointEntity[] Unwrap(Point[] o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IPointEntity[] Unwrap(IEnumerable<Point> o)
{
return (from x in o
select Unwrap(x)).ToArray();
}
internal static IPointEntity Unwrap(Point o)
{
return o.PointEntity;
}
public static Point ByCoordinates([Scaling()] double x = 0, [Scaling()] double y = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
x,
y
});
x /= DesignScriptEntity.scaleFactor;
y /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.PointByCoordinates(x, y), true);
}
public static Point Origin()
{
return Wrap(HostFactory.Factory.PointOrigin(), true);
}
public static Point ByCoordinates([Scaling()] double x = 0, [Scaling()] double y = 0, [Scaling()] double z = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
x,
y,
z
});
x /= DesignScriptEntity.scaleFactor;
y /= DesignScriptEntity.scaleFactor;
z /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.PointByCoordinates(x, y, z), true);
}
public static Point ByCartesianCoordinates([DefaultArgument("Autodesk.DesignScript.Geometry.CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem coordinateSystem, [Scaling()] double x = 0, [Scaling()] double y = 0, [Scaling()] double z = 0)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
x,
y,
z
});
x /= DesignScriptEntity.scaleFactor;
y /= DesignScriptEntity.scaleFactor;
z /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.PointByCartesianCoordinates(CoordinateSystem.Unwrap(coordinateSystem), x, y, z), true);
}
public static Point ByCylindricalCoordinates([DefaultArgument("Autodesk.DesignScript.Geometry.CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem coordinateSystem, double angle = 0, [Scaling()] double elevation = 0, [Scaling()] double radius = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
elevation,
radius
});
elevation /= DesignScriptEntity.scaleFactor;
radius /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.PointByCylindricalCoordinates(CoordinateSystem.Unwrap(coordinateSystem), angle, elevation, radius), true);
}
public static Point BySphericalCoordinates([DefaultArgument("Autodesk.DesignScript.Geometry.CoordinateSystem.ByOrigin(0, 0, 0)")] CoordinateSystem coordinateSystem, double phi = 0, double theta = 0, [Scaling()] double radius = 1)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
radius
});
radius /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.PointBySphericalCoordinates(CoordinateSystem.Unwrap(coordinateSystem), phi, theta, radius), true);
}
public static Point[] PruneDuplicates(IEnumerable<Point> points, [Scaling()] double tolerance = 0.001)
{
DesignScriptEntity.CheckArgsForAsmExtents(new List<double> {
tolerance
});
tolerance /= DesignScriptEntity.scaleFactor;
return Wrap(HostFactory.Factory.PointPruneDuplicates(Unwrap(points), tolerance), true);
}
public Vector AsVector()
{
return Vector.Wrap(PointEntity.AsVector(), true);
}
public Point Add(Vector vectorToAdd)
{
return Wrap(PointEntity.Add(Vector.Unwrap(vectorToAdd)), true);
}
public Point Subtract(Vector vectorToSubtract)
{
return Wrap(PointEntity.Subtract(Vector.Unwrap(vectorToSubtract)), true);
}
public Geometry[] Project(Geometry baseGeometry, Vector projectionDirection)
{
return Geometry.Wrap(PointEntity.Project(Geometry.Unwrap(baseGeometry), Vector.Unwrap(projectionDirection)));
}
}
}