Exemple #1
0
        /// <summary>
        /// Flip the endpoints of the AKT_Line segment.
        /// </summary>
        public void Flip()
        {
            AKT_Point3d from = this.From;

            this.From = this.To;
            this.To   = from;
        }
Exemple #2
0
        /// <summary>
        /// Gets the parameters of the point on the plane closest to a test point.
        /// </summary>
        /// <param name="testPoint">Point to get close to.</param>
        /// <param name="s">Parameter along plane X-direction.</param>
        /// <param name="t">Parameter along plane Y-direction.</param>
        /// <returns>
        /// true if a parameter could be found,
        /// false if the point could not be projected successfully.
        /// </returns>
        /// <example>
        /// <code source="examples\vbnet\ex_addlineardimension2.vb" lang="vbnet" />
        /// <code source="examples\cs\ex_addlineardimension2.cs" lang="cs" />
        /// <code source="examples\py\ex_addlineardimension2.py" lang="py" />
        /// </example>
        public bool ClosestParameter(AKT_Point3d testPoint, out double s, out double t)
        {
            AKT_Vector3d vector3d = testPoint - this.Origin;

            s = vector3d * this.XAxis;
            t = vector3d * this.YAxis;
            return(true);
        }
Exemple #3
0
 public AKT_Plane(AKT_Point3d origin, AKT_Vector3d vX, AKT_Vector3d vY)
 {
     this.m_origin = origin;
     this.m_xaxis  = vX;
     this.m_yaxis  = vY;
     this.m_zaxis  = AKT_Vector3d.CrossProduct(vX, vY);
     this.guid     = Guid.Empty;
 }
Exemple #4
0
        /// <summary>
        /// Constructs a new AKT_Line segment from start point, direction and length.
        /// </summary>
        /// <param name="start">Start point of AKT_Line segment.</param>
        /// <param name="direction">Direction of AKT_Line segment.</param>
        /// <param name="length">Length of AKT_Line segment.</param>
        public AKT_Line(AKT_Point3d start, AKT_Vector3d direction, double length)
        {
            AKT_Vector3d vector3d = direction;

            if (!vector3d.Unitize())
            {
                vector3d = new AKT_Vector3d(0, 0, 1);
            }
            this.m_from = start;
            this.m_to   = start + (vector3d * length);
        }
Exemple #5
0
        /// <summary>
        /// Gets the point on the plane closest to a test point.
        /// </summary>
        /// <param name="testPoint">Point to get close to.</param>
        /// <returns>
        /// The point on the plane that is closest to testPoint,
        /// or Point3d.Unset on failure.
        /// </returns>
        public AKT_Point3d ClosestPoint(AKT_Point3d testPoint)
        {
            double num;
            double num1;

            if (!this.ClosestParameter(testPoint, out num, out num1))
            {
                return(AKT_Point3d.Unset);
            }
            return(this.PointAt(num, num1));
        }
Exemple #6
0
        public static double VectorAngle(AKT_Vector3d a, AKT_Vector3d b, AKT_Plane plane)
        {
            AKT_Point3d origin  = plane.Origin + a;
            AKT_Point3d point3d = plane.Origin + b;

            origin  = plane.ClosestPoint(origin);
            point3d = plane.ClosestPoint(point3d);
            a       = origin - plane.Origin;
            b       = point3d - plane.Origin;
            if (!a.Unitize())
            {
                return(-1.23432101234321E+308);
            }
            if (!b.Unitize())
            {
                return(-1.23432101234321E+308);
            }
            double num = a * b;

            if (num >= 1)
            {
                num = 1;
            }
            else if (num < -1)
            {
                num = -1;
            }
            double num1 = Math.Acos(num);

            if (Math.Abs(num1) < 1E-64)
            {
                return(0);
            }
            if (Math.Abs(num1 - 3.14159265358979) < 1E-64)
            {
                return(3.14159265358979);
            }
            AKT_Vector3d vector3d = AKT_Vector3d.CrossProduct(a, b);

            if (plane.ZAxis.IsParallelTo(vector3d) == 1)
            {
                return(num1);
            }
            return(6.28318530717959 - num1);
        }
Exemple #7
0
        public static double LineToPointDistance2D(AKT_Line l, AKT_Point3d p, bool isSegment = true)
        {
            AKT_Point3d  pointA = l.To;
            AKT_Point3d  pointB = l.To;
            AKT_Point3d  pointC = p;
            AKT_Vector3d pA     = new AKT_Vector3d(p, pointA);

            throw new NotImplementedException();
            //AKT_Vector3d dist = AKT_Vector3d.CrossProduct(l.Direction, pA) / l.Length;
            //if (isSegment)
            //{
            //    double dot1 = DotProduct(pointA, pointB, p);
            //    if (dot1 > 0)
            //        return Distance(pointB, p);

            //    double dot2 = DotProduct(pointB, pointA, p);
            //    if (dot2 > 0)
            //        return Distance(pointA, p);
            //}
            //return Math.Abs(dist);
        }
Exemple #8
0
        /// <summary>
        /// Extend the AKT_Line by custom distances on both sides.
        /// </summary>
        /// <param name="startLength">
        /// Distance to extend the AKT_Line at the start point.
        /// Positive distance result in longer AKT_Lines.
        /// </param>
        /// <param name="endLength">
        /// Distance to extend the AKT_Line at the end point.
        /// Positive distance result in longer AKT_Lines.
        /// </param>
        /// <returns>true on success, false on failure.</returns>
        public bool Extend(double startLength, double endLength)
        {
            if (this.Length == 0)
            {
                return(false);
            }
            AKT_Point3d  mFrom       = this.m_from;
            AKT_Point3d  mTo         = this.m_to;
            AKT_Vector3d unitTangent = this.UnitTangent;

            if (startLength != 0)
            {
                mFrom = this.m_from - (startLength * unitTangent);
            }
            if (endLength != 0)
            {
                mTo = this.m_to + (endLength * unitTangent);
            }
            this.m_from = mFrom;
            this.m_to   = mTo;
            return(true);
        }
Exemple #9
0
 public AKT_Vector3d(AKT_Point3d end, AKT_Point3d start)
     : this(end - start)
 {
 }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of a vector, copying the three components from the three coordinates of a point.
 /// </summary>
 /// <param name="point">The point to copy from.</param>
 public AKT_Vector3d(AKT_Point3d point)
     : this(point.m_x, point.m_y, point.m_z)
 {
 }
Exemple #11
0
 /// <summary>
 /// Constructs a new AKT_Line segment between two points.
 /// </summary>
 /// <param name="x0">The X coordinate of the first point.</param>
 /// <param name="y0">The Y coordinate of the first point.</param>
 /// <param name="z0">The Z coordinate of the first point.</param>
 /// <param name="x1">The X coordinate of the second point.</param>
 /// <param name="y1">The Y coordinate of the second point.</param>
 /// <param name="z1">The Z coordinate of the second point.</param>
 public AKT_Line(double x0, double y0, double z0, double x1, double y1, double z1)
 {
     this.m_from = new AKT_Point3d(x0, y0, z0);
     this.m_to   = new AKT_Point3d(x1, y1, z1);
 }
Exemple #12
0
 /// <summary>
 /// Constructs a new AKT_Line segment from start point and span vector.
 /// </summary>
 /// <param name="start">Start point of AKT_Line segment.</param>
 /// <param name="span">Direction and length of AKT_Line segment.</param>
 public AKT_Line(AKT_Point3d start, AKT_Vector3d span)
 {
     this.m_from = start;
     this.m_to   = start + span;
 }
Exemple #13
0
 /// <summary>
 /// Constructs a new AKT_Line segment between two points.
 /// </summary>
 /// <param name="from">Start point of AKT_Line.</param>
 /// <param name="to">End point of AKT_Line.</param>
 public AKT_Line(AKT_Point3d from, AKT_Point3d to)
 {
     this.m_from = from;
     this.m_to   = to;
 }
Exemple #14
0
 public AKT_NurbsPoint(AKT_Point3d pnt3d, double w)
 {
     this.pnt3d = pnt3d;
     this.w     = w;
 }
Exemple #15
0
 public AKT_Plane(AKT_Point3d origin, AKT_Point3d pntX, AKT_Point3d pntY)
     : this(origin, new AKT_Vector3d(pntX, origin), new AKT_Vector3d(pntY, origin))
 {
 }
Exemple #16
0
 public AKT_Plane(AKT_Point3d origin)
     : this(origin, AKT_Vector3d.XAxis, AKT_Vector3d.YAxis)
 {
 }