/// <summary> /// Initializes a new instance of the <see cref="CartesianOffset"/> struct. /// </summary> /// <param name="deltaX">The x-axis offset from the origin.</param> /// <param name="deltaY">The y-axis offset from the origin.</param> /// <param name="tolerance">The tolerance.</param> public CartesianOffset( double deltaX, double deltaY, double tolerance = Numbers.ZeroTolerance) { I = new CartesianCoordinate(0, 0); J = new CartesianCoordinate(deltaX, deltaY); Tolerance = tolerance; }
/// <summary> /// Initializes a new instance of the <see cref="CartesianOffset"/> struct. /// </summary> /// <param name="i">The first coordinate.</param> /// <param name="j">The second coordinate.</param> /// <param name="tolerance">The tolerance.</param> public CartesianOffset( CartesianCoordinate i, CartesianCoordinate j, double tolerance = Numbers.ZeroTolerance) { I = i; J = j; Tolerance = tolerance; }
/// <summary> /// Creates an angular offset between 3 points. /// The sign of the offset is dependent upon the ordering of the points. /// </summary> /// <param name="point1">The point1.</param> /// <param name="point2">The point2.</param> /// <param name="point3">The point3.</param> /// <returns>Angle.</returns> public static AngularOffset CreateFromPoints( CartesianCoordinate point1, CartesianCoordinate point2, CartesianCoordinate point3) { Angle angle1 = new Vector(point1, point2).Angle(); Angle angle2 = new Vector(point2, point3).Angle(); return(angle1.OffsetFrom(angle2)); }
/// <summary> /// To the trilinear. /// </summary> /// <param name="vertexA">The vertex a.</param> /// <param name="vertexB">The vertex b.</param> /// <param name="vertexC">The vertex c.</param> /// <returns>TrilinearCoordinate.</returns> public TrilinearCoordinate ToTrilinear(CartesianCoordinate vertexA, CartesianCoordinate vertexB, CartesianCoordinate vertexC) { double sideA = (vertexC - vertexB).Length(); double sideB = (vertexA - vertexC).Length(); double sideC = (vertexB - vertexA).Length(); return(new TrilinearCoordinate( x: Alpha / sideA, y: Beta / sideB, z: Gamma / sideC )); }
/// <summary> /// To the barycentric. /// </summary> /// <param name="vertexA">The vertex a.</param> /// <param name="vertexB">The vertex b.</param> /// <param name="vertexC">The vertex c.</param> /// <returns>BarycentricCoordinate.</returns> public BarycentricCoordinate ToBarycentric(CartesianCoordinate vertexA, CartesianCoordinate vertexB, CartesianCoordinate vertexC) { double sideA = (vertexC - vertexB).Length(); double sideB = (vertexA - vertexC).Length(); double sideC = (vertexB - vertexA).Length(); return(new BarycentricCoordinate ( alpha: X *sideA, beta: Y *sideB, gamma: Z *sideC )); }
/// <summary> /// To the cartesian. /// </summary> /// <param name="vertexA">The vertex a.</param> /// <param name="vertexB">The vertex b.</param> /// <param name="vertexC">The vertex c.</param> /// <returns>CartesianCoordinate.</returns> public CartesianCoordinate ToCartesian(CartesianCoordinate vertexA, CartesianCoordinate vertexB, CartesianCoordinate vertexC) { double sideA = (vertexC - vertexB).Length(); double sideB = (vertexA - vertexC).Length(); double sideC = (vertexB - vertexA).Length(); double denominator = sideA * X + sideB * Y + sideC * Z; double weight1 = (sideA * X) / denominator; double weight2 = (sideB * Y) / denominator; double weight3 = (sideC * Z) / denominator; CartesianCoordinate pVector = weight1 * vertexA + weight2 * vertexB + weight3 * vertexC; return(new CartesianCoordinate(pVector.X, pVector.Y, Tolerance)); }
/// <summary> /// To the cartesian. /// </summary> /// <param name="vertexA">The vertex a.</param> /// <param name="vertexB">The vertex b.</param> /// <param name="vertexC">The vertex c.</param> /// <returns>CartesianCoordinate.</returns> public CartesianCoordinate ToCartesian(CartesianCoordinate vertexA, CartesianCoordinate vertexB, CartesianCoordinate vertexC) { double x = Alpha * vertexA.X + Beta * vertexB.X + Gamma * vertexC.X; double y = Alpha * vertexA.Y + Beta * vertexB.Y + Gamma * vertexC.Y; return(new CartesianCoordinate(x, y, Tolerance)); }
/// <summary> /// Returns the positive angle [degrees] from the x-axis, counter-clockwise, of the coordinates. /// </summary> /// <param name="coordinate">The coordinate.</param> /// <returns>System.Double.</returns> public static double AsRadians(CartesianCoordinate coordinate) { return(AsRadians(coordinate.X, coordinate.Y)); }
/// <summary> /// Creates an Angle from two points. /// The angle is assumed to lie between the line formed by the two points, and the positive horizontal axis. /// </summary> /// <param name="point1">The first point.</param> /// <param name="point2">The second point.</param> /// <returns>Angle.</returns> public static Angle CreateFromPoints(CartesianCoordinate point1, CartesianCoordinate point2) { Vector vector = new Vector(point1, point2); return(vector.Angle()); }
/// <summary> /// Creates an Angle from a point. /// The angle is assumed to lie between the origin, point, and positive horizontal axis. /// </summary> /// <param name="point">The point.</param> /// <returns>Angle.</returns> public static Angle CreateFromPoint(CartesianCoordinate point) { Vector vector = new Vector(CartesianCoordinate.Origin(), point); return(vector.Angle()); }
/// <summary> /// The separation distance between the provided points. /// </summary> /// <param name="coord1">The coord1.</param> /// <param name="coord2">The coord2.</param> /// <returns>System.Double.</returns> public static double Separation(CartesianCoordinate coord1, CartesianCoordinate coord2) { return(AlgebraLibrary.SRSS((coord2.X - coord1.X), (coord2.Y - coord1.Y))); }