コード例 #1
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;
        }
コード例 #2
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;
        }
コード例 #3
0
ファイル: FiniteElement.cs プロジェクト: xiaoxiongnpu/SharpFE
        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));
        }
コード例 #4
0
ファイル: PointTest.cs プロジェクト: iainsproat/SharpFE
        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);
        }
コード例 #5
0
ファイル: PointTest.cs プロジェクト: xiaoxiongnpu/SharpFE
        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);
        }
コード例 #6
0
ファイル: UnboundedLine.cs プロジェクト: iainsproat/SharpFE
        /// <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);
        }
コード例 #7
0
ファイル: BoundedLine.cs プロジェクト: iainsproat/SharpFE
 public BoundedLine(CartesianPoint startOfLine, CartesianPoint endOfLine)
     : base(endOfLine.Subtract(startOfLine), startOfLine)
 {
     // empty
 }