public static void Initialization() { CurveLimit curveLimitInitialize = new CurveLimit(curve); Assert.AreEqual(CartesianCoordinate.Origin().X, curveLimitInitialize.Limit.X); Assert.AreEqual(CartesianCoordinate.Origin().Y, curveLimitInitialize.Limit.Y); }
public static void Initialization_at_Local_Origin_with_Radii() { // Expected Complex Results CartesianCoordinate center = CartesianCoordinate.Origin(); Angle rotation = Angle.Origin(); double a = 5; double b = 3; double c = (a.Squared() - b.Squared()).Sqrt(); double e = c / a; double p = a * (1 - e.Squared()); double xe = a.Squared() / c; CartesianCoordinate vertexMajor1 = new CartesianCoordinate(a, 0); CartesianCoordinate vertexMajor2 = new CartesianCoordinate(-a, 0); CartesianCoordinate vertexMinor1 = new CartesianCoordinate(0, b); CartesianCoordinate vertexMinor2 = new CartesianCoordinate(0, -b); CartesianCoordinate focus1 = new CartesianCoordinate(c, 0); CartesianCoordinate focus2 = new CartesianCoordinate(-c, 0); CartesianCoordinate directrix1I = new CartesianCoordinate(xe, 0); CartesianCoordinate directrix1J = new CartesianCoordinate(xe, 1); CartesianCoordinate directrix2I = new CartesianCoordinate(-xe, 0); CartesianCoordinate directrix2J = new CartesianCoordinate(-xe, 1); // Initialization EllipticalCurve curve = new EllipticalCurve(a, b, center, rotation, Tolerance); // Simple properties Assert.AreEqual(a, curve.DistanceFromVertexMajorToLocalOrigin, Tolerance); Assert.AreEqual(b, curve.DistanceFromVertexMinorToMajorAxis, Tolerance); Assert.AreEqual(c, curve.DistanceFromFocusToLocalOrigin, Tolerance); Assert.AreEqual(e, curve.Eccentricity, Tolerance); Assert.AreEqual(p, curve.SemilatusRectumDistance, Tolerance); Assert.AreEqual(xe, curve.DistanceFromDirectrixToLocalOrigin, Tolerance); Assert.AreEqual(xe - c, curve.DistanceFromFocusToDirectrix, Tolerance); // Position properties Assert.AreEqual(Angle.Origin(), curve.Rotation); Assert.AreEqual(focus1, curve.Focus); Assert.AreEqual(center, curve.LocalOrigin); // Coordinate properties Assert.AreEqual(vertexMajor1, curve.VerticesMajor.Item1); Assert.AreEqual(vertexMajor2, curve.VerticesMajor.Item2); Assert.AreEqual(vertexMinor1, curve.VerticesMinor.Item1); Assert.AreEqual(vertexMinor2, curve.VerticesMinor.Item2); Assert.AreEqual(vertexMajor1, curve.Range.Start.Limit); Assert.AreEqual(vertexMajor1, curve.Range.End.Limit); Assert.AreEqual(directrix1I, curve.Directrix.ControlPointI); Assert.AreEqual(directrix1J, curve.Directrix.ControlPointJ); // Complex Properties unique to Ellipse Assert.AreEqual(focus2, curve.Focus2); Assert.AreEqual(directrix2I, curve.Directrix2.ControlPointI); Assert.AreEqual(directrix2J, curve.Directrix2.ControlPointJ); }
public static void Initialization() { Curve curve = new LinearCurve(new CartesianCoordinate(-1, -2, Tolerance), new CartesianCoordinate(4, 3, Tolerance)); curve.Tolerance = Tolerance; CurveRange range = new CurveRange(curve); Assert.AreEqual(CartesianCoordinate.Origin(), range.Start.Limit); Assert.AreEqual(CartesianCoordinate.Origin(), range.End.Limit); }
/// <summary> /// Initializes a new instance of the <see cref="BezierCurve"/> class. /// </summary> /// <param name="length">The length.</param> /// <param name="numberOfControlPoints">The number of control points.</param> /// <param name="tolerance">Tolerance to apply to the curve.</param> public BezierCurve( double length, int numberOfControlPoints = _maxNumberOfControlPoints, double tolerance = DEFAULT_TOLERANCE) : base(tolerance) { NumberOfControlPoints = getNumberOfControlPoints(numberOfControlPoints); CartesianCoordinate pointI = CartesianCoordinate.Origin(); CartesianCoordinate pointJ = new CartesianCoordinate(length, 0); double handleLength = getHandleLength(pointI, pointJ); HandleI = new CurveHandle(pointI, handleLength); HandleJ = getCurveHandleJ(pointJ, handleLength); }
public static void Initialization_with_Coordinates_Results_in_Object_with_Immutable_Coordinates_Properties_List() { CartesianCoordinate localOriginInGlobal = new CartesianCoordinate(3, 2); CartesianCoordinate localAxisXPtInGlobal = new CartesianCoordinate(5, 4); Transformations transformations = new Transformations(localOriginInGlobal, localAxisXPtInGlobal); AngularOffset angularOffset = new AngularOffset(Numbers.Pi / 4); CartesianOffset offset = localOriginInGlobal.OffsetFrom(CartesianCoordinate.Origin()); Assert.AreEqual(localOriginInGlobal, transformations.LocalOrigin); Assert.AreEqual(localAxisXPtInGlobal, transformations.LocalAxisX); Assert.AreEqual(offset, transformations.Displacement); Assert.AreEqual(angularOffset.ToAngle().Degrees, transformations.Rotation.ToAngle().Degrees, Tolerance); }
public static void IsClosedCurve_Returns_False_When_Curve_Does_Not_Close_to_Form_a_Shape() { EllipticalCurve curve = new EllipticalCurve(a, b, CartesianCoordinate.Origin(), Angle.Origin(), Tolerance); Assert.IsTrue(curve.Range.Start.Limit == curve.Range.End.Limit); Assert.IsTrue(curve.IsClosedCurve()); // Change limits CartesianCoordinate newRangeLimit = new CartesianCoordinate(-2, 2); curve.Range.End.SetLimitByCoordinate(newRangeLimit); Assert.IsFalse(curve.Range.Start.Limit == curve.Range.End.Limit); Assert.IsFalse(curve.IsClosedCurve()); }
public static void Initialization_at_Local_Origin_with_Distances() { // Expected Complex Results CartesianCoordinate center = CartesianCoordinate.Origin(); Angle rotation = Angle.Origin(); double a = 5; double b = 2 * a; double c = a; double e = 1; double p = 2 * a; double xe = a; CartesianCoordinate vertexMajor1 = center; CartesianCoordinate vertexMinor1 = new CartesianCoordinate(a, b, Tolerance); CartesianCoordinate vertexMinor2 = new CartesianCoordinate(a, -b, Tolerance); CartesianCoordinate focus1 = new CartesianCoordinate(c, 0, Tolerance); CartesianCoordinate directrix1I = new CartesianCoordinate(-xe, 0, Tolerance); CartesianCoordinate directrix1J = new CartesianCoordinate(-xe, 1, Tolerance); // Initialization ParabolicCurve curve = new ParabolicCurve(a, center, rotation, Tolerance); // Simple properties Assert.AreEqual(0, curve.DistanceFromVertexMajorToLocalOrigin, Tolerance); Assert.AreEqual(b, curve.DistanceFromVertexMinorToMajorAxis, Tolerance); Assert.AreEqual(a, curve.DistanceFromFocusToLocalOrigin, Tolerance); Assert.AreEqual(e, curve.Eccentricity, Tolerance); Assert.AreEqual(p, curve.SemilatusRectumDistance, Tolerance); Assert.AreEqual(xe, curve.DistanceFromDirectrixToLocalOrigin, Tolerance); Assert.AreEqual(c + xe, curve.DistanceFromFocusToDirectrix, Tolerance); // Position properties Assert.AreEqual(Angle.Origin(), curve.Rotation); Assert.AreEqual(focus1, curve.Focus); Assert.AreEqual(center, curve.LocalOrigin); // Coordinate properties Assert.AreEqual(vertexMajor1, curve.VerticesMajor.Item1); Assert.AreEqual(vertexMajor1, curve.VerticesMajor.Item2); Assert.AreEqual(vertexMinor1, curve.VerticesMinor.Item1); Assert.AreEqual(vertexMinor2, curve.VerticesMinor.Item2); Assert.AreEqual(directrix1I, curve.Directrix.ControlPointI); Assert.AreEqual(directrix1J, curve.Directrix.ControlPointJ); Assert.AreEqual(vertexMajor1, curve.Range.Start.Limit); Assert.AreEqual(vertexMajor1, curve.Range.End.Limit); }
/// <summary> /// Initializes a new instance of the <see cref="Transformations"/> class. /// </summary> /// <param name="localOriginInGlobal">The local origin in global coordinates.</param> /// <param name="localAxisXPtInGlobal">Any point along the local x-axis in global coordinates.</param> public Transformations(CartesianCoordinate localOriginInGlobal, CartesianCoordinate localAxisXPtInGlobal) { LocalOrigin = localOriginInGlobal; LocalAxisX = localAxisXPtInGlobal; Displacement = localOriginInGlobal.OffsetFrom(CartesianCoordinate.Origin()); if (localAxisXPtInGlobal.Y == localOriginInGlobal.Y) { Rotation = new AngularOffset(); } else { Rotation = AngularOffset.CreateFromPoints( localAxisXPtInGlobal, localOriginInGlobal, new CartesianCoordinate(localOriginInGlobal.X - 1, localOriginInGlobal.Y) ); } }
/// <summary> /// The component second differentical as a function of the supplied parameter. /// </summary> /// <param name="parameter">The parameter, such as relative position between 0 & 1, or the angle in radians.</param> /// <returns>System.Double.</returns> public override CartesianCoordinate PrimeDoubleByParameter(double parameter) { return(CartesianCoordinate.Origin()); }
public static void Initialization_at_Offset_From_Origin_with_Distances(double x, double y) { // Expected Complex Results CartesianCoordinate center = new CartesianCoordinate(x, y); Angle rotation = Angle.Origin(); double a = 5; double b = 3; double c = (a.Squared() + b.Squared()).Sqrt(); double e = c / a; double p = a * (e.Squared() - 1); double xe = a.Squared() / c; CartesianCoordinate vertexMajor1 = new CartesianCoordinate(a, 0); CartesianCoordinate vertexMajor2 = new CartesianCoordinate(-a, 0); CartesianCoordinate vertexMinor1 = new CartesianCoordinate(a, b); CartesianCoordinate vertexMinor2 = new CartesianCoordinate(a, -b); CartesianCoordinate vertexMinor1_2 = new CartesianCoordinate(-a, b); CartesianCoordinate vertexMinor2_2 = new CartesianCoordinate(-a, -b); CartesianCoordinate focus1 = new CartesianCoordinate(c, 0); CartesianCoordinate focus2 = new CartesianCoordinate(-c, 0); CartesianCoordinate directrix1I = new CartesianCoordinate(xe, 0); CartesianCoordinate directrix1J = new CartesianCoordinate(xe, 1); CartesianCoordinate directrix2I = new CartesianCoordinate(-xe, 0); CartesianCoordinate directrix2J = new CartesianCoordinate(-xe, 1); CartesianCoordinate Asymptote1I = CartesianCoordinate.Origin(); CartesianCoordinate Asymptote1J = vertexMinor1; CartesianCoordinate Asymptote2I = CartesianCoordinate.Origin(); CartesianCoordinate Asymptote2J = vertexMinor2; // Initialization HyperbolicCurve curve = new HyperbolicCurve(a, b, center, rotation, Tolerance); // Simple properties Assert.AreEqual(a, curve.DistanceFromVertexMajorToLocalOrigin, Tolerance); Assert.AreEqual(b, curve.DistanceFromVertexMinorToMajorAxis, Tolerance); Assert.AreEqual(c, curve.DistanceFromFocusToLocalOrigin, Tolerance); Assert.AreEqual(e, curve.Eccentricity, Tolerance); Assert.AreEqual(p, curve.SemilatusRectumDistance, Tolerance); Assert.AreEqual(xe, curve.DistanceFromDirectrixToLocalOrigin, Tolerance); Assert.AreEqual(c - xe, curve.DistanceFromFocusToDirectrix, Tolerance); // Position properties Assert.AreEqual(rotation, curve.Rotation); Assert.AreEqual(focus1, curve.Focus); Assert.AreEqual(center, curve.LocalOrigin); // Coordinate properties Assert.AreEqual(vertexMajor1, curve.VerticesMajor.Item1); Assert.AreEqual(vertexMajor2, curve.VerticesMajor.Item2); Assert.AreEqual(vertexMinor1, curve.VerticesMinor.Item1); Assert.AreEqual(vertexMinor2, curve.VerticesMinor.Item2); Assert.AreEqual(vertexMajor1, curve.Range.Start.Limit); Assert.AreEqual(vertexMajor1, curve.Range.End.Limit); Assert.AreEqual(directrix1I, curve.Directrix.ControlPointI); Assert.AreEqual(directrix1J, curve.Directrix.ControlPointJ); // Complex Properties unique to Hyperbola Assert.AreEqual(focus2, curve.Focus2); Assert.AreEqual(directrix2I, curve.Directrix2.ControlPointI); Assert.AreEqual(directrix2J, curve.Directrix2.ControlPointJ); Assert.AreEqual(vertexMinor1_2, curve.VerticesMinor2.Item1); Assert.AreEqual(vertexMinor2_2, curve.VerticesMinor2.Item2); Assert.AreEqual(Asymptote1I, curve.Asymptotes.Item1.ControlPointI); Assert.AreEqual(Asymptote1J, curve.Asymptotes.Item1.ControlPointJ); Assert.AreEqual(Asymptote2I, curve.Asymptotes.Item2.ControlPointI); Assert.AreEqual(Asymptote2J, curve.Asymptotes.Item2.ControlPointJ); }