Exemplo n.º 1
0
 /// <summary>
 /// Orthogonal projection of the circle to line
 /// </summary>
 public Segment3d ProjectionTo(Line3d l)
 {
     double s = _r * Cos(l.AngleTo(this));
     Vector3d v = l.Direction.Normalized;
     Point3d p = _point.ProjectionTo(l);
     return new Segment3d(p.Translate(-s * v), p.Translate(s * v));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Orthogonal projection of the ellipse to plane
        /// </summary>
        public Ellipse ProjectionTo(Plane3d s)
        {
            Point3d c = _point.ProjectionTo(s);
            Point3d q = _point.Translate(_v1).ProjectionTo(s);
            Point3d p = _point.Translate(_v2).ProjectionTo(s);

            Vector3d f1 = new Vector3d(c, p);
            Vector3d f2 = new Vector3d(c, q);

            double   t0 = 0.5 * Atan2(2 * f1 * f2, f1 * f1 - f2 * f2);
            Vector3d v1 = f1 * Cos(t0) + f2 * Sin(t0);
            Vector3d v2 = f1 * Cos(t0 + PI / 2) + f2 * Sin(t0 + PI / 2);

            return(new Ellipse(c, v1, v2));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reflect vector in given plane
        /// </summary>
        public Vector3d ReflectIn(Plane3d s)
        {
            Point3d p1 = new Point3d(0, 0, 0, this._coord);
            Point3d p2 = p1.Translate(this);

            return(new Vector3d(p1.ReflectIn(s), p2.ReflectIn(s)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Orthogonal projection of ellipsoid to line.
        /// </summary>
        public Segment3d ProjectionTo(Line3d l)
        {
            //Stephen B. Pope "Algorithms for Ellipsoids"
            // https://tcg.mae.cornell.edu/pubs/Pope_FDA_08.pdf

            Coord3d  lc = new Coord3d(_point, _v1, _v2);
            Point3d  x0 = l.Point.ConvertTo(lc);
            Vector3d v  = l.Direction.ConvertTo(lc);

            Matrix3d L_T = Matrix3d.DiagonalMatrix(this.A, this.B, this.C);
            Vector3d c   = new Vector3d(0.0, 0.0, 0.0, lc);
            double   s0  = v * (c - x0.ToVector) / (v * v);
            Vector3d w   = L_T * v / (v * v);
            Point3d  P1  = x0.Translate((s0 + w.Norm) * v);
            Point3d  P2  = x0.Translate((s0 - w.Norm) * v);

            return(new Segment3d(P1, P2));
        }
Exemplo n.º 5
0
 /// <summary>
 /// Translate box by a vector
 /// </summary>
 public Box3d Translate(Vector3d v)
 {
     return(new Box3d(_center.Translate(v), _lx, _ly, _lz));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Translate triangle by a vector
 /// </summary>
 public Triangle Translate(Vector3d v)
 {
     return(new Triangle(_a.Translate(v), _b.Translate(v), _c.Translate(v)));
 }
Exemplo n.º 7
0
        /// <summary>
        /// Orthogonal projection of the sphere to the line
        /// </summary>
        public Segment3d ProjectionTo(Line3d l)
        {
            Point3d p = this.Center.ProjectionTo(l);

            return(new Segment3d(p.Translate(this.R * l.Direction.Normalized), p.Translate(-this.R * l.Direction.Normalized)));
        }