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; }
public CartesianPoint ConvertGlobalCoordinatesToLocalCoordinates(CartesianPoint globalPoint) { GeometricVector localCoordRelativeToLocalOrigin = globalPoint.Subtract(this.LocalOrigin); KeyedSquareMatrix <DegreeOfFreedom> rotationMatrix = CalculateElementRotationMatrix(); CartesianPoint localCoord = new CartesianPoint(rotationMatrix.Multiply(localCoordRelativeToLocalOrigin)); return(new CartesianPoint(localCoord)); }
public void Can_subtract_another_point() { CartesianPoint SUT = new CartesianPoint(3, 4, 5); CartesianPoint other = new CartesianPoint(5, 4, 3); GeometricVector result = SUT.Subtract(other); Assert.AreEqual(-2, result.X); Assert.AreEqual(0, result.Y); Assert.AreEqual(2, result.Z); }
/// <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); }
public BoundedLine(CartesianPoint startOfLine, CartesianPoint endOfLine) : base(endOfLine.Subtract(startOfLine), startOfLine) { // empty }