예제 #1
0
파일: AKT_Plane.cs 프로젝트: LorenzG/Viz3D
        /// <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);
        }
예제 #2
0
        /// <summary>
        /// Computes the distance between two points.
        /// </summary>
        /// <param name="other">Other point for distance measurement.</param>
        /// <returns>The length of the AKT_Line between this and the other point; or 0 if any of the points is not valid.</returns>
        /// <example>
        /// <code source="examples\vbnet\ex_intersectcurves.vb" lang="vbnet" />
        /// <code source="examples\cs\ex_intersectcurves.cs" lang="cs" />
        /// <code source="examples\py\ex_intersectcurves.py" lang="py" />
        /// </example>
        public double DistanceTo(AKT_Point3d other)
        {
            double mX = other.m_x - this.m_x;
            double mY = other.m_y - this.m_y;
            double mZ = other.m_z - this.m_z;

            return(AKT_Vector3d.GetLengthHelper(mX, mY, mZ));
        }
예제 #3
0
파일: AKT_Plane.cs 프로젝트: LorenzG/Viz3D
 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;
 }
예제 #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);
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
0
        /// <summary>
        /// Gets the unit tangent vector along the AKT_PolyLine at the given parameter.
        /// The integer part of the parameter indicates the index of the segment.
        /// </summary>
        /// <param name="t">AKT_PolyLine parameter.</param>
        /// <returns>The tangent along the AKT_PolyLine at t.</returns>
        public AKT_Vector3d TangentAt(double t)
        {
            int count = this.points.Count();

            if (count < 2)
            {
                return(AKT_Vector3d.Zero);
            }
            int num = (int)Math.Floor(t);

            if (num < 0)
            {
                num = 0;
            }
            else if (num > count - 2)
            {
                num = count - 2;
            }
            AKT_Vector3d mItems = this.points[num + 1] - this.points[num];

            mItems.Unitize();
            return(mItems);
        }
예제 #8
0
 /// <summary>
 /// Subtracts a vector from a point.
 /// <para>(Provided for languages that do not support operator overloading. You can use the - operator otherwise)</para>
 /// </summary>
 /// <param name="vector">A vector.</param>
 /// <param name="point">A point.</param>
 /// <returns>A new point that is the difference of point minus vector.</returns>
 public static AKT_Point3d Subtract(AKT_Point3d point, AKT_Vector3d vector)
 {
     return(new AKT_Point3d(point.m_x - vector.m_x, point.m_y - vector.m_y, point.m_z - vector.m_z));
 }
예제 #9
0
 /// <summary>
 /// Sums up a point and a vector, and returns a new point.
 /// <para>(Provided for languages that do not support operator overloading. You can use the + operator otherwise)</para>
 /// </summary>
 /// <param name="point">A point.</param>
 /// <param name="vector">A vector.</param>
 /// <returns>A new point that results from the addition of point and vector.</returns>
 public static AKT_Point3d Add(AKT_Point3d point, AKT_Vector3d vector)
 {
     return(new AKT_Point3d(point.m_x + vector.m_x, point.m_y + vector.m_y, point.m_z + vector.m_z));
 }
예제 #10
0
 /// <summary>
 /// Initializes a new point by copying coordinates from the components of a vector.
 /// </summary>
 /// <param name="vector">A vector.</param>
 public AKT_Point3d(AKT_Vector3d vector)
 {
     this.m_x = vector.m_x;
     this.m_y = vector.m_y;
     this.m_z = vector.m_z;
 }
예제 #11
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;
 }