Ejemplo n.º 1
0
        /// <summary>
        /// Method to convert a 3D Line to 3D <see cref="MathNet.Spatial.Euclidean.Vector3D"/>
        /// </summary>
        /// <param name="_3DLinetobeVectored"></param>
        /// <returns></returns>
        public static MathNet.Spatial.Euclidean.Vector3D GetMathNetVector3D(Line _3DLinetobeVectored)
        {
            MathNet.Spatial.Euclidean.Vector3D vector3D = new MathNet.Spatial.Euclidean.Vector3D(_3DLinetobeVectored.EndPoint.X - _3DLinetobeVectored.StartPoint.X,
                                                                                                 _3DLinetobeVectored.EndPoint.Y - _3DLinetobeVectored.StartPoint.Y,
                                                                                                 _3DLinetobeVectored.EndPoint.Z - _3DLinetobeVectored.StartPoint.Z);

            return(vector3D);
        }
        /// <summary>
        /// Method to find the angle between 2 vectors in any required View or in 3D.
        /// Make the Vector a 2D vector by setting any of the axis to 0 to get the FV, TV or SV
        /// </summary>
        /// <example>For top view the 2D vector will consist of only Z and Y coordinates</example>
        /// <param name="_vAngleOfThis">The 3D vector converted to 2D whose angle is to be found with respect to a reference vector</param>
        /// <param name="_vAngleWithThis">The 3D vector converted to 2D which is the reference vector</param>
        /// <param name="_vNormalToViewPlane">The 3D vector about which the <paramref name="_vAngleOfThis"/> is rotated to get the angle about <paramref name="_vAngleWithThis"/> </param>
        /// <returns>The <see cref="Angle"/> between the 1st 2 vectors passed</returns>
        public static Angle AngleInRequiredView(MathNet.Spatial.Euclidean.Vector3D _vAngleOfThis, MathNet.Spatial.Euclidean.Vector3D _vAngleWithThis, MathNet.Spatial.Euclidean.Vector3D _vNormalToViewPlane)
        {
            ///<summary>Temp Angle declared</summary>
            Angle angle;

            ///<summary>Using the <see cref="MathNet.Spatial.Euclidean.Vector3D.SignedAngleTo(MathNet.Spatial.Euclidean.Vector3D, MathNet.Spatial.Euclidean.UnitVector3D)"/> method to calculate the angle between the 2 vectors</summary>
            //angle = _vAngleOfThis.SignedAngleTo(_vAngleWithThis, _vNormalToViewPlane.Normalize());
            angle = _vAngleWithThis.SignedAngleTo(_vAngleOfThis, _vNormalToViewPlane.Normalize());

            return(angle);
        }
 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     MathNet.Spatial.Euclidean.Vector3D vector = (MathNet.Spatial.Euclidean.Vector3D)value;
     writer.WriteStartObject();
     writer.WritePropertyName("x");
     writer.WriteValue(vector.X);
     writer.WritePropertyName("y");
     writer.WriteValue(vector.Y);
     writer.WritePropertyName("z");
     writer.WriteValue(vector.Z);
     writer.WriteEndObject();
 }