public Segment2D(Point2D basePoint, Direction2D direction, Distance length) { if (length == ZeroDistance) { throw new Exception("Segment length must be greater than zero."); } BasePoint = basePoint; EndPoint = basePoint + direction.ToVector(length); Length = length.AbsoluteValue(); }
public static Direction2D?To2D(this Direction direction) { if (Math.Abs(direction.Z) > ZeroDotProductTolerance) { throw new Exception("Expected direction to be zero in the z coordinate."); } if (direction.HasDirection()) { return(Direction2D.Create(direction.X, direction.Y)); } return(null); }
public Segment2D(Direction2D direction, Distance magnitude) : this(Point2D.Origin, direction, magnitude) { }
public static Direction To3D(this Direction2D direction) => new Direction(direction.X, direction.Y);
public static DecomposedAngle AngleFromPositiveX(this Direction2D imageOfPositiveX) => new DecomposedAngle(imageOfPositiveX);
/// <summary> /// Get the <see cref="DecomposedAngle" /> needed to rotate the first <see cref="Direction2D" /> onto the /// second. /// </summary> public static DecomposedAngle CounterclockwiseAngleTo(this Direction2D preimage, Direction2D image) => new DecomposedAngle(preimage.DotProduct(image), preimage.RotateQuarterTurn().DotProduct(image));
public DecomposedAngle Negate() => new DecomposedAngle(Direction2D.UnsafeCreateFromNormalized(CosineOfAngle, -SineOfAngle));
/// <summary> /// Construct the angle from the positive x-axis to the specified point. /// </summary> public static DecomposedAngle?FromPositiveX(Distance x, Distance y) => Direction2D.Create(x, y)?.AngleFromPositiveX();
/// <summary> /// Construct the counterclockwise angle from the positive x-axis to the specified point, or throw an /// <see cref="Exception"/> if the point is too close to the origin. /// </summary> public DecomposedAngle(double x, double y) : this(Direction2D.Create(x, y)) { }
public DecomposedAngle(Direction2D imageOfPositiveXAxis) { ImageOfPositiveXAxis = imageOfPositiveXAxis; }