Example #1
0
        public override bool Equals(object theSegment)
        {
            if (!(theSegment is CCLine3))
            {
                return(false);
            }

            CCLine3 mySegment = (CCLine3)theSegment;

            return(mySegment.Start().Equals(Start()) && mySegment.End().Equals(End()) || mySegment.Start().Equals(End()) && mySegment.End().Equals(Start()));
        }
Example #2
0
        public virtual CCLine3 ClosestLineBetween(CCLine3 theOtherLine)
        {
            Vector3 p13 = _myStart - theOtherLine._myStart;
            Vector3 p43 = theOtherLine._myEnd - theOtherLine._myStart;

            if (Math.Abs(p43.x) <= Double.Epsilon && Math.Abs(p43.y) <= Double.Epsilon && Math.Abs(p43.z) <= Double.Epsilon)
            {
                return(null);
            }

            Vector3 p21 = _myEnd - _myStart;

            if (Math.Abs(p21.x) <= Double.Epsilon && Math.Abs(p21.y) <= Double.Epsilon && Math.Abs(p21.z) <= Double.Epsilon)
            {
                return(null);
            }

            float d4321 = Vector3.Dot(p43, p21);
            float d4343 = Vector3.Dot(p43, p43);
            float d2121 = Vector3.Dot(p21, p21);

            float denom = d2121 * d4343 - d4321 * d4321;

            if (Math.Abs(denom) < Double.Epsilon)
            {
                return(null);
            }

            float d1343 = Vector3.Dot(p13, p43);
            float d1321 = Vector3.Dot(p13, p21);

            float numer = d1343 * d4321 - d1321 * d4343;

            float mua = numer / denom;
            float mub = (d1343 + d4321 * (mua)) / d4343;

            return(new CCLine3(
                       _myStart.x + mua * p21.x,
                       _myStart.y + mua * p21.y,
                       _myStart.z + mua * p21.z,
                       theOtherLine._myStart.x + mub * p43.x,
                       theOtherLine._myStart.y + mub * p43.y,
                       theOtherLine._myStart.z + mub * p43.z
                       ));
        }
Example #3
0
 public CCLine3(CCLine3 theSegment) : this(theSegment._myStart, theSegment._myEnd)
 {
 }