Ejemplo n.º 1
0
        /// <summary>
        /// Gets the 2D coordinates as seen from a calculated plane.
        /// </summary>
        /// <param name="cc">3D coordinates to convert.</param>
        /// <returns>The converted 2D coordinates.</returns>
        private Cartesian2dCoordinate GetFromProjection(Cartesian3dCoordinate cc)
        {
            // Project the coordinates on the reference
            ParametricLine        projectionLine  = this.Plane.GetPerpendicular(cc);
            Cartesian3dCoordinate planeCoordinate = this.Plane.GetIntersection(projectionLine);

            Cartesian3dCoordinate ccOnX = planeCoordinate.TransposeFromReferential(this.Plane.Normal);

            return(GetFromFront(ccOnX));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the intersection point coordinate between the current plane and the speicifed line.
        /// </summary>
        /// <param name="l">Line that should cross the plane at the seeked intersection point.</param>
        /// <returns>The cartesian coordinates of the intersection point between the line and the Plane.</returns>
        /// <remarks>
        /// Formula :
        ///
        /// A(x1 + at) + B(y1 + bt) + C(z1 + ct) + D = 0
        ///
        /// Then giving t :
        ///
        ///      -(Ax1 + By1 + Cz1 + D)
        /// t = ------------------------
        ///           Aa + Bb + Cc
        ///
        /// Coordinates are then :
        ///
        ///           a(Ax1 + By1 + Cz1 + D)             b(Ax1 + By1 + Cz1 + D)             c(Ax1 + By1 + Cz1 + D)
        /// x = x1 - ------------------------  y = y1 - ------------------------  z = z1 - ------------------------
        ///                Aa + Bb + Cc                       Aa + Bb + Cc                       Aa + Bb + Cc
        ///
        /// </remarks>
        public Cartesian3dCoordinate GetIntersection(ParametricLine l)
        {
            if (l.IsParallelTo(this))
            {
                throw new InvalidOperationException("Cannot Get Intersection between a Plane and a parallel line.");
            }

            double divisor   = GetSumOfAbcProduct(l);
            double planePart = ((this.A * l.X) + (this.B * l.Y) + (this.C * l.Z) + this.D) / divisor;

            return(new Cartesian3dCoordinate(
                       l.X - (l.A * planePart),
                       l.Y - (l.B * planePart),
                       l.Z - (l.C * planePart)
                       ));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the sum of products of the A, B and C factor of the plane and parametric line formula.
 /// </summary>
 /// <param name="l">Parametric line with which we calculate the product.</param>
 /// <returns>Result of the sum of the product of the A, B and C factor of the plane and parametric line formula.</returns>
 private double GetSumOfAbcProduct(ParametricLine l) => (this.A * l.A) + (this.B * l.B) + (this.C * l.C);