public UnboundedLine(GeometricVector vectorOfLine, CartesianPoint pointOnLine) { Guard.AgainstNullArgument(vectorOfLine, "vectorOfLine"); Guard.AgainstNullArgument(pointOnLine, "pointOnLine"); this.Vector = vectorOfLine; this.PointOnLine = pointOnLine; }
public static double AreaQuadrilateral(CartesianPoint point0, CartesianPoint point1, CartesianPoint point2, CartesianPoint point3) { GeometricVector diagonal1 = point2.Subtract(point0); GeometricVector diagonal2 = point3.Subtract(point1); double crossProduct = (diagonal1[DegreeOfFreedom.X] * diagonal2[DegreeOfFreedom.Y]) - (diagonal1[DegreeOfFreedom.Y] * diagonal2[DegreeOfFreedom.X]); return(0.5 * crossProduct); }
/// <summary> /// /// </summary> /// <param name="point0"></param> /// <param name="point1"></param> /// <param name="point2"></param> /// <returns></returns> public static double AreaTriangle(CartesianPoint point0, CartesianPoint point1, CartesianPoint point2) { GeometricVector side01 = point1.Subtract(point0); GeometricVector side02 = point2.Subtract(point0); GeometricVector crossProduct = side01.CrossProduct(side02); double quadArea = crossProduct.Norm(2); return(quadArea * 0.5); }
/// <summary> /// Calculates the perpendicular line from this line to the given point /// </summary> /// <param name="pointNotOnLine"></param> /// <returns></returns> public BoundedLine PerpendicularLineTo(CartesianPoint pointNotOnLine) { GeometricVector betweenPoints = pointNotOnLine.Subtract(this.PointOnLine); GeometricVector normalizedLineVector = this.Vector.Normalize(2); double projectionDistanceOfEndPointAlongLine = betweenPoints.DotProduct(normalizedLineVector); GeometricVector vectorAlongLine = normalizedLineVector.Multiply(projectionDistanceOfEndPointAlongLine); CartesianPoint endPointOfPerpendicularLine = this.PointOnLine.Add(vectorAlongLine); GeometricVector result = pointNotOnLine.Subtract(endPointOfPerpendicularLine); return(new BoundedLine(endPointOfPerpendicularLine, result)); }
/// <summary> /// Calculates the perpendicular line from this line to the given point /// </summary> /// <param name="pointNotOnLine"></param> /// <returns></returns> public GeometricVector PerpendicularLineTo(CartesianPoint pointOnLine, CartesianPoint pointToCalculatePerpendicularVectorTo) { GeometricVector betweenPoints = pointToCalculatePerpendicularVectorTo.Subtract(pointOnLine); GeometricVector normalizedLineVector = this.Normalize(2); double projectionDistanceOfEndPointAlongLine = betweenPoints.DotProduct(normalizedLineVector); GeometricVector scaledVectorAlongLine = normalizedLineVector.Multiply(projectionDistanceOfEndPointAlongLine); CartesianPoint startPointOfPerpendicularLine = pointOnLine.Add(scaledVectorAlongLine); GeometricVector result = pointToCalculatePerpendicularVectorTo.Subtract(startPointOfPerpendicularLine); return(result); }
public virtual bool IsOnLine(CartesianPoint pointToCheck) { GeometricVector normalizedVector = Vector.Normalize(2); GeometricVector vectorToPointToCheck = this.PointOnLine.VectorTo(pointToCheck); vectorToPointToCheck = vectorToPointToCheck.Normalize(2); if (normalizedVector.Equals(vectorToPointToCheck)) { return(true); } GeometricVector inversedNormalizedVector = normalizedVector.Negate(); return(inversedNormalizedVector.Equals(vectorToPointToCheck)); }
public override bool IsOnLine(CartesianPoint pointToCheck) { GeometricVector normalizedVector = this.Vector.Normalize(2); GeometricVector vectorToPointToCheck = this.Start.VectorTo(pointToCheck); if (vectorToPointToCheck.X == 0 && vectorToPointToCheck.Y == 0 && vectorToPointToCheck.Z == 0) { // the pointToCheck is at the start of the bounded line return(true); } GeometricVector normalizedVectorToPointToCheck = vectorToPointToCheck.Normalize(2); if (!normalizedVector.Equals(normalizedVectorToPointToCheck)) { return(false); } double norm = this.Vector.Norm(2); double normToPointToCheck = vectorToPointToCheck.Norm(2); return(normToPointToCheck <= norm); }
public BoundedLine(CartesianPoint startOfLine, GeometricVector vectorOfLineFromStartToEnd) : base(vectorOfLineFromStartToEnd, startOfLine) { // empty }
public GeometricVector CrossProduct(GeometricVector other) { return(new GeometricVector(base.CrossProduct(other))); }
/// <summary> /// IEquatable implementation /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(GeometricVector other) { return(base.Equals(other)); }
/// <summary> /// Adds a vector to this point to calculate the location of a new point /// </summary> /// <param name="vectorToNewPoint"></param> /// <returns></returns> public CartesianPoint Add(GeometricVector vectorToNewPoint) { return(new CartesianPoint(base.Add(vectorToNewPoint))); }
public Plane(GeometricVector planeNormal, CartesianPoint pointOnPlane) { this.Normal = planeNormal; this.Point = pointOnPlane; }