Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 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
     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);
 }