getPoint() public method

public getPoint ( ) : Point3d
return Point3d
Example #1
0
        /**
         * Computes the point resulting from the intersection with another line
         *
         * @param otherLine the other line to apply the intersection. The lines are supposed
         * to intersect
         * @return point resulting from the intersection. If the point coundn't be obtained, return null
         */
        public Point3d?computeLineIntersection(Line otherLine)
        {
            //x = x1 + a1*t = x2 + b1*s
            //y = y1 + a2*t = y2 + b2*s
            //z = z1 + a3*t = z2 + b3*s

            Point3d  linePoint     = otherLine.getPoint();
            Vector3d lineDirection = otherLine.getDirection();

            float t;

            if (Math.Abs(direction.Y * lineDirection.X - direction.X * lineDirection.Y) > TOL)
            {
                t = (-point.Y * lineDirection.X + linePoint.Y * lineDirection.X + lineDirection.Y * point.X - lineDirection.Y * linePoint.X) / (direction.Y * lineDirection.X - direction.X * lineDirection.Y);
            }
            else if (Math.Abs(-direction.X * lineDirection.Z + direction.Z * lineDirection.X) > TOL)
            {
                t = -(-lineDirection.Z * point.X + lineDirection.Z * linePoint.X + lineDirection.X * point.Z - lineDirection.X * linePoint.Z) / (-direction.X * lineDirection.Z + direction.Z * lineDirection.X);
            }
            else if (Math.Abs(-direction.Z * lineDirection.Y + direction.Y * lineDirection.Z) > TOL)
            {
                t = (point.Z * lineDirection.Y - linePoint.Z * lineDirection.Y - lineDirection.Z * point.Y + lineDirection.Z * linePoint.Y) / (-direction.Z * lineDirection.Y + direction.Y * lineDirection.Z);
            }
            else
            {
                return(null);
            }

            float x = point.X + direction.X * t;
            float y = point.Y + direction.Y * t;
            float z = point.Z + direction.Z * t;

            return(new Point3d(x, y, z));
        }
Example #2
0
        /**
         * Computes the point resulting from the intersection with another line
         *
         * @param otherLine the other line to apply the intersection. The lines are supposed
         * to intersect
         * @return point resulting from the intersection. If the point coundn't be obtained, return null
         */
        public Point3d computeLineIntersection(Line otherLine)
        {
            //x = x1 + a1*t = x2 + b1*s
            //y = y1 + a2*t = y2 + b2*s
            //z = z1 + a3*t = z2 + b3*s

            Point3d  linePoint     = otherLine.getPoint();
            Vector3d lineDirection = otherLine.getDirection();

            double t;

            if (Math.Abs(direction.y * lineDirection.x - direction.x * lineDirection.y) > TOL)
            {
                t = (-point.y * lineDirection.x + linePoint.y * lineDirection.x + lineDirection.y * point.x - lineDirection.y * linePoint.x) / (direction.y * lineDirection.x - direction.x * lineDirection.y);
            }
            else if (Math.Abs(-direction.x * lineDirection.z + direction.z * lineDirection.x) > TOL)
            {
                t = -(-lineDirection.z * point.x + lineDirection.z * linePoint.x + lineDirection.x * point.z - lineDirection.x * linePoint.z) / (-direction.x * lineDirection.z + direction.z * lineDirection.x);
            }
            else if (Math.Abs(-direction.z * lineDirection.y + direction.y * lineDirection.z) > TOL)
            {
                t = (point.z * lineDirection.y - linePoint.z * lineDirection.y - lineDirection.z * point.y + lineDirection.z * linePoint.y) / (-direction.z * lineDirection.y + direction.y * lineDirection.z);
            }
            else
            {
                return(null);
            }

            double x = point.x + direction.x * t;
            double y = point.y + direction.y * t;
            double z = point.z + direction.z * t;

            return(new Point3d(x, y, z));
        }
Example #3
0
        /**
         * Computes the point resulting from the intersection with another line
         *
         * @param otherLine the other line to apply the intersection. The lines are supposed
         * to intersect
         * @return point resulting from the intersection. If the point coundn't be obtained, return null
         */
        public Point3d computeLineIntersection(Line otherLine)
        {
            //x = x1 + a1*t = x2 + b1*s
            //y = y1 + a2*t = y2 + b2*s
            //z = z1 + a3*t = z2 + b3*s

            Point3d linePoint = otherLine.getPoint();
            Vector3d lineDirection = otherLine.getDirection();

            double t;
            if (Math.Abs(direction.y * lineDirection.x - direction.x * lineDirection.y) > TOL)
            {
                t = (-point.y * lineDirection.x + linePoint.y * lineDirection.x + lineDirection.y * point.x - lineDirection.y * linePoint.x) / (direction.y * lineDirection.x - direction.x * lineDirection.y);
            }
            else if (Math.Abs(-direction.x * lineDirection.z + direction.z * lineDirection.x) > TOL)
            {
                t = -(-lineDirection.z * point.x + lineDirection.z * linePoint.x + lineDirection.x * point.z - lineDirection.x * linePoint.z) / (-direction.x * lineDirection.z + direction.z * lineDirection.x);
            }
            else if (Math.Abs(-direction.z * lineDirection.y + direction.y * lineDirection.z) > TOL)
            {
                t = (point.z * lineDirection.y - linePoint.z * lineDirection.y - lineDirection.z * point.y + lineDirection.z * linePoint.y) / (-direction.z * lineDirection.y + direction.y * lineDirection.z);
            }
            else
                return null;

            double x = point.x + direction.x * t;
            double y = point.y + direction.y * t;
            double z = point.z + direction.z * t;

            return new Point3d(x, y, z);
        }