Esempio n. 1
0
        public UnboundedLine(GeometricVector vectorOfLine, CartesianPoint pointOnLine)
        {
            Guard.AgainstNullArgument(vectorOfLine, "vectorOfLine");
            Guard.AgainstNullArgument(pointOnLine, "pointOnLine");

            this.Vector      = vectorOfLine;
            this.PointOnLine = pointOnLine;
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
        /// <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));
        }
Esempio n. 5
0
        /// <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);
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 public BoundedLine(CartesianPoint startOfLine, GeometricVector vectorOfLineFromStartToEnd)
     : base(vectorOfLineFromStartToEnd, startOfLine)
 {
     // empty
 }
Esempio n. 9
0
 public GeometricVector CrossProduct(GeometricVector other)
 {
     return(new GeometricVector(base.CrossProduct(other)));
 }
Esempio n. 10
0
 /// <summary>
 /// IEquatable implementation
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(GeometricVector other)
 {
     return(base.Equals(other));
 }
Esempio n. 11
0
 /// <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)));
 }
Esempio n. 12
0
 public Plane(GeometricVector planeNormal, CartesianPoint pointOnPlane)
 {
     this.Normal = planeNormal;
     this.Point  = pointOnPlane;
 }