Beispiel #1
0
        public float Multiply(LineSeg3D ls1, LineSeg3D ls2)
        {
            Vector3D d1 = new Vector3D(ls1._ep - ls1._sp);
            Vector3D d2 = new Vector3D(ls2._ep - ls2._sp);

            return(d1.GetX() * d2.GetX() + d1.GetY() * d2.GetY() + d1.GetZ() * d2.GetZ());
        }
Beispiel #2
0
        public LineSeg3D Subtract(LineSeg3D line, Point3D point)
        {
            LineSeg3D l = new LineSeg3D();

            l.Equals(line);
            l -= point;
            return(l);
        }
Beispiel #3
0
        public LineSeg3D Add(LineSeg3D line, Point3D point)
        {
            LineSeg3D l = new LineSeg3D();

            l.Equals(line);
            l += point;
            return(l);
        }
Beispiel #4
0
        // Rotate a line segment.
        // param l the line segment to be rotated
        // @returns the resulting rotated line segment
        public LineSeg3D Rotate(LineSeg3D l)
        {
            // Simply rotate both lines
            Vector3D  i      = this.Imaginary();
            Vector3D  ns     = new Vector3D(Vector3D.VectorProduct(i, l.StartPoint()));
            Vector3D  ne     = new Vector3D(Vector3D.VectorProduct(i, l.EndPoint()));
            Vector3D  deltas = new Vector3D(_r * ns - (Vector3D)(Vector3D.VectorProduct(ns, i)));
            Vector3D  deltae = new Vector3D(_r * ne - (Vector3D)(Vector3D.VectorProduct(ne, i)));
            LineSeg3D result = new LineSeg3D(l.StartPoint() + 2.0f * deltas, l.EndPoint() + 2.0f * deltae);

            return(result);
        }
Beispiel #5
0
 public LineSeg3D Equals(LineSeg3D ls)
 {
     if (this != ls)
     {
         _sp = ls._sp;
         _ep = ls._ep;
     }
     else
     {
         Debug.WriteLine("Error: copying LineSeg3D into itself!");
     }
     return(this);
 }
Beispiel #6
0
        // Rotate a line segment.
        // @param l the line segment to be rotated
        // @returns the resulting rotated line segment
        public LineSeg3D Rotate(LineSeg3D l)
        {
            // Simply rotate both lines
            float angle = (float)Math.Sqrt(_x * _x + _y * _y + _z * _z);

            if (angle < 1e-8)
            {
                return(l);
            }
            float    sn     = (float)Math.Sin(angle);
            float    cs     = (float)Math.Cos(angle);
            Vector3D axis   = new Vector3D(_x / angle, _y / angle, _z / angle);
            Vector3D ns     = new Vector3D(Point3D.VectorProduct(axis, l.StartPoint()));
            Vector3D ne     = new Vector3D(Point3D.VectorProduct(axis, l.EndPoint()));
            Vector3D deltas = new Vector3D(sn * ns + (cs - 1.0f) * (Point3D.VectorProduct(ns, axis)));
            Vector3D deltae = new Vector3D(sn * ne + (cs - 1.0f) * (Point3D.VectorProduct(ne, axis)));

            return(new LineSeg3D(l.StartPoint() + deltas, l.EndPoint() + deltae));
        }
Beispiel #7
0
        public float Multiply(LineSeg3D ls1, LineSeg3D ls2) 
        {
            Vector3D d1 = new Vector3D(ls1._ep - ls1._sp);
            Vector3D d2 = new Vector3D(ls2._ep - ls2._sp);

            return (d1.GetX() * d2.GetX() + d1.GetY() * d2.GetY() + d1.GetZ() * d2.GetZ());
        }
Beispiel #8
0
 public bool EqualTo (LineSeg3D ls) 
 {
     return ((_sp==ls._sp) && (_ep==ls._ep));
 }
Beispiel #9
0
 public LineSeg3D Equals (LineSeg3D ls) 
 {
     if (this != ls) 
     {
         _sp = ls._sp;
         _ep = ls._ep;
     } 
     else 
     {
         Debug.WriteLine("Error: copying LineSeg3D into itself!");
     }
     return this;
 }
Beispiel #10
0
 public LineSeg3D Subtract (LineSeg3D line, Point3D point)
 {
     LineSeg3D l = new LineSeg3D();
     l.Equals(line);
     l -= point;
     return l;
 }
Beispiel #11
0
 public LineSeg3D Add (LineSeg3D line, Point3D point)
 {
     LineSeg3D l = new LineSeg3D();
     l.Equals(line);
     l += point;
     return l;
 }
Beispiel #12
0
 // Rotate a line segment.
 // param l the line segment to be rotated 
 // @returns the resulting rotated line segment
 public LineSeg3D Rotate(LineSeg3D l)
 {
     // Simply rotate both lines
     Vector3D i = this.Imaginary();
     Vector3D ns = new Vector3D(Vector3D.VectorProduct(i, l.StartPoint()));
     Vector3D ne = new Vector3D(Vector3D.VectorProduct(i, l.EndPoint()));
     Vector3D deltas = new Vector3D(_r * ns - (Vector3D)(Vector3D.VectorProduct(ns, i)));
     Vector3D deltae = new Vector3D(_r * ne - (Vector3D)(Vector3D.VectorProduct(ne, i)));
     LineSeg3D result = new LineSeg3D(l.StartPoint() + 2.0f * deltas, l.EndPoint()   + 2.0f * deltae);
     return (result);
 }
Beispiel #13
0
 public float Norm(LineSeg3D ls)
 {
     return((float)Math.Sqrt((ls._ep._x - ls._sp._x) * (ls._ep._x - ls._sp._x)
                             + (ls._ep._y - ls._sp._y) * (ls._ep._y - ls._sp._y)
                             + (ls._ep._z - ls._sp._z) * (ls._ep._z - ls._sp._z)));
 }
Beispiel #14
0
 public float Norm2(LineSeg3D ls)
 {
     return((ls._ep._x - ls._sp._x) * (ls._ep._x - ls._sp._x)
            + (ls._ep._y - ls._sp._y) * (ls._ep._y - ls._sp._y)
            + (ls._ep._z - ls._sp._z) * (ls._ep._z - ls._sp._z));
 }
Beispiel #15
0
 public bool EqualTo(LineSeg3D ls)
 {
     return((_sp == ls._sp) && (_ep == ls._ep));
 }
Beispiel #16
0
        public float Norm2(LineSeg3D ls)
        {
            return ((ls._ep._x-ls._sp._x)*(ls._ep._x-ls._sp._x) 
	                + (ls._ep._y-ls._sp._y)*(ls._ep._y-ls._sp._y) 
	                + (ls._ep._z-ls._sp._z)*(ls._ep._z-ls._sp._z));
        }
Beispiel #17
0
        public float Norm(LineSeg3D ls)
        {
            return (float)Math.Sqrt((ls._ep._x - ls._sp._x) * (ls._ep._x - ls._sp._x) 
	                         + (ls._ep._y-ls._sp._y)*(ls._ep._y-ls._sp._y) 
	                         + (ls._ep._z-ls._sp._z)*(ls._ep._z-ls._sp._z));
        }
Beispiel #18
0
 // Rotate a line segment.
 // @param l the line segment to be rotated
 // @returns the resulting rotated line segment
 public LineSeg3D Multiply(LineSeg3D l)
 {
     return(this.Rotate(l));
 }
Beispiel #19
0
 // Rotate a line segment.
 // @param l the line segment to be rotated
 // @returns the resulting rotated line segment
 public LineSeg3D Multiply (LineSeg3D l)
 {
     return (this.Rotate(l));
 }
Beispiel #20
0
 // Rotate a line segment.
 // @param l the line segment to be rotated
 // @returns the resulting rotated line segment
 public LineSeg3D Rotate(LineSeg3D l)
 {
     // Simply rotate both lines
     float angle = (float)Math.Sqrt(_x * _x + _y * _y + _z * _z);
     if (angle < 1e-8) 
     {
         return l;
     }
     float sn = (float)Math.Sin(angle);
     float cs = (float)Math.Cos(angle);
     Vector3D axis = new Vector3D(_x / angle, _y / angle, _z / angle);
     Vector3D ns = new Vector3D(Point3D.VectorProduct(axis, l.StartPoint()));
     Vector3D ne = new Vector3D(Point3D.VectorProduct(axis, l.EndPoint()));
     Vector3D deltas = new Vector3D(sn * ns + (cs - 1.0f) * (Point3D.VectorProduct(ns, axis)));
     Vector3D deltae = new Vector3D(sn * ne + (cs - 1.0f) * (Point3D.VectorProduct(ne, axis)));
     return new LineSeg3D(l.StartPoint() + deltas, l.EndPoint() + deltae);
 }