예제 #1
0
        private double getDistTo(sg_Vector3 pt)
        {
            double l1 = sg_math.getDist(_pt1, pt);
            double l2 = sg_math.getDist(pt, _pt2);

            return(getDistToPoint(l1, l2));
        }
예제 #2
0
        public bool is_Viald()
        {
            sg_Vector3 v = new sg_Vector3(-999999, -999999, -999999);
            double     l = sg_math.getDist(this, v);

            return(sg_math.isZero(l));
        }
예제 #3
0
        public bool IsInclude(sg_Vector3 pt, out double pathlength)
        {
            pathlength = 0;
            if (!(_box.contain(pt)))
            {
                return(false);
            }

            double l1 = sg_math.getDist(_pt1, pt);
            double l2 = sg_math.getDist(pt, _pt2);

            double d = getDistToPoint(l1, l2);

            if (sg_math.isZero(d))
            {
                if ((_l > l1 && _l > l2) ||
                    (sg_math.isEquel(l1, _l) && sg_math.isEquel(0.0, l2)) ||
                    (sg_math.isEquel(l2, _l) && sg_math.isEquel(0.0, l1)))
                {
                    pathlength = l1;
                    return(true);
                }
            }
            return(false);
        }
예제 #4
0
        public bool IsBeforePt1(sg_Vector3 pt, out double length)
        {
            length = 0;
            if ((_box.contain(pt)))
            {
                return(false);
            }
            if (_needCal)
            {
                _cal_l();
            }
            double l1 = sg_math.getDist(_pt1, pt);
            double l2 = sg_math.getDist(pt, _pt2);
            double d  = getDistToPoint(l1, l2);

            if (sg_math.isZero(d))
            {
                if (l2 > _l && l2 > l1)
                {
                    length = l1;
                    return(true);
                }
            }
            return(false);
        }
예제 #5
0
        public bool IsInclude(sg_Vector3 pt, out double pathlength)
        {
            pathlength = 0;
            if (!_box.contain(pt))
            {
                return(false);
            }
            double l = 0;


            for (int i = 0; i < _lines.Count; i++)
            {
                sg_line line = _lines[i];
                if (line.IsInclude(pt, out l))
                {
                    pathlength = pathlength + l;
                    return(true);
                }
                else
                {
                    pathlength = pathlength + line.getLength();
                }
            }
            return(false);
        }
예제 #6
0
 public sg_line(sg_Vector3 pt1, sg_Vector3 pt2)
 {
     _pt1     = pt1;
     _pt2     = pt2;
     _box     = new SGBox3D(_pt1, _pt2);
     _needCal = true;
 }
예제 #7
0
        public sg_Vector3(double angle, double dip)
        {
            sg_Vector3 v = getNormal(angle, dip);

            this.x = v.x;
            this.y = v.y;
            this.z = v.z;
        }
예제 #8
0
        public static double getDist(sg_Vector3 pt1, sg_Vector3 pt2)
        {
            double dx = pt1.x - pt2.x;
            double dy = pt1.y - pt2.y;
            double dz = pt1.z - pt2.z;

            return(Math.Sqrt(dx * dx + dy * dy + dz * dz));
        }
예제 #9
0
 public sg_polyline(sg_Vector3 pt1, sg_Vector3 pt2)
 {
     _lines.Clear();
     _box    = new SGBox3D(pt1, pt1);
     _lastpt = pt1;
     _l      = -1;
     appendPoint(pt2);
 }
예제 #10
0
        public double getDist(sg_Vector3 pt)
        {
            sg_Vector3        v    = new sg_Vector3(pt);
            sg_Transformation m    = new sg_Transformation(_v, certenPt);
            sg_Vector3        newv = m.inverse(v);

            return(Math.Abs(newv.z));
        }
예제 #11
0
        public void appendPoint(sg_Vector3 pt)
        {
            sg_line line = new sg_line(_lastpt, pt);

            _lines.Add(line);
            _lastpt = pt;
            _box    = _box + line.Box;
        }
예제 #12
0
//
//  POINT3D sg_plane::get3DPoint(POINT3D pt) const
//  {
//      return get3DPoint(pt.x, pt.y, pt.z);
//  }

        public sg_Vector3 get3DPoint(double x, double y, double z)
        {
            sg_Vector3        v    = new sg_Vector3(x, y, z);
            sg_Transformation m    = new sg_Transformation(_v, certenPt);
            sg_Vector3        newv = m.apply(v);

            return(new sg_Vector3(newv.x, newv.y, newv.z));
        }
예제 #13
0
 public static double getAngle(sg_Vector3 v)
 {
     if (v.isZero())
     {
         return(-99999);
     }
     return(sg_math.ArcToAngle(Math.Acos(v.z / v.length)));
 }
예제 #14
0
        public sg_Vector3 crossMul(sg_Vector3 v)
        {
            double x = ((this.y * v.z) - (this.z * v.y));
            double y = ((this.z * v.x) - (this.x * v.z));
            double z = ((this.x * v.y) - (this.y * v.x));

            return(new sg_Vector3(x, y, z));
        }
예제 #15
0
 public bool isVertical(sg_Vector3 v)
 {
     if (isZero() || v.isZero())
     {
         return(false);
     }
     return(dotMul(v) == 0);
 }
예제 #16
0
        public static sg_Vector3 getNormal(sg_Vector3 p1, sg_Vector3 p2, sg_Vector3 p3)
        {
            sg_Vector3 v   = p3 - p1;
            sg_Vector3 ret = v.crossMul(p2 - p1);

            ret.Normalize();
            return(ret);
        }
예제 #17
0
        public bool isParallel(sg_Vector3 v)
        {
            if (isZero() || v.isZero())
            {
                return(false);
            }
            sg_Vector3 newv = this.crossMul(v);

            return(newv.isZero());
        }
예제 #18
0
        public void Move(sg_Vector3 v)
        {
            if (!isSized())
            {
                return;
            }
            sg_Vector3 pt1 = new sg_Vector3(v.x, v.y, v.z);
            sg_Vector3 pt2 = get3DPoint(pt1);

            certenPt = pt2;
        }
예제 #19
0
        public sg_plane(sg_Vector3 v)
        {
            certenPt = new sg_Vector3(0, 0, 0);

            Width  = -1;
            Height = -1;

            __state = PlaneState.UnKnow;

            _v = new sg_Vector3(v);
        }
예제 #20
0
        public bool IsAfterLastPt(sg_Vector3 pt, out double length)
        {
            length = 0;
            if (_lines.Count == 0)
            {
                return(false);
            }
            sg_line line = _lines[_lines.Count - 1];

            return(line.IsAfterPt2(pt, out length));
        }
예제 #21
0
        public bool IsBeforePt1(sg_Vector3 pt, out double length)
        {
            length = 0;
            if (_lines.Count == 0)
            {
                return(false);
            }
            sg_line line = _lines[0];

            return(line.IsBeforePt1(pt, out length));
        }
예제 #22
0
 public sg_Vector3 apply(sg_Vector3 v)
 {
     double[] input  = { v.x, v.y, v.z };
     double[] output = { 0, 0, 0 };
     for (int m = 0; m < 3; m++)
     {
         for (int n = 0; n < 3; n++)
         {
             output[m] += (double)(input[n] * _r[m, n]);
         }
     }
     return(new sg_Vector3(output[0] + _t[0], output[1] + _t[1], output[2] + _t[2]));
 }
예제 #23
0
        public sg_Vector3 getPointAt(int index)
        {
            sg_Vector3 pt = new sg_Vector3(-999999, -999999, -999999);

            if (index == 0)
            {
                return(_lines[0].StartPoint);
            }
            if (index <= (_lines.Count))
            {
                return(_lines[index - 1].EndPoint);
            }
            return(pt);
        }
예제 #24
0
        public sg_plane(sg_Vector3 pt1, sg_Vector3 pt2, sg_Vector3 pt3)
        {
            sg_Vector3 v = sg_Vector3.getNormal(pt1, pt2, pt3);

            _v = new sg_Vector3(v);

            double dip = v.getDip();
            double aaa = v.getAngle();

            certenPt = new sg_Vector3((pt1.x + pt3.x) / 2.0, (pt1.y + pt3.y) / 2.0, (pt1.z + pt3.z) / 2.0);

            Width  = sg_math.getDist(pt1, pt2);
            Height = sg_math.getDist(pt2, pt3);
        }
예제 #25
0
        public bool get2DPoint(sg_Vector3 pt, out sg_Vector3 retPt)
        {
            sg_Vector3 v = new sg_Vector3(pt.x, pt.y, pt.z);

            retPt = new sg_Vector3(0, 0, 0);
            sg_Transformation m    = new sg_Transformation(_v, certenPt);
            sg_Vector3        newv = m.inverse(v);

            if (!sg_math.isZero(newv.z))
            {
                return(false);
            }
            retPt = new sg_Vector3(newv);
            return(true);
        }
예제 #26
0
//      public sg_Transformation(sg_Vector3 v0,  sg_Vector3 v1,  sg_Vector3 v2)
//      {
//          sg_Vector3 W1 = v1 - v0;
//          sg_Vector3 W3 = W1.crossMul(v2 - v0);
//          sg_Vector3 W2 = W3.crossMul(W1);
//
//          W1.Normalize();
//          W2.Normalize();
//          W3.Normalize();
//
//          _r[0,0] = W1.x; _r[0,1] = W2.x; _r[0,2] = W3.x;
//          _r[1,0] = W1.y; _r[1,1] = W2.y; _r[1,2] = W3.y;
//          _r[2,0] = W1.z; _r[2,1] = W2.z; _r[2,2] = W3.z;
//
//          _t[0] = v0.x; _t[1] = v0.y; _t[2] = v0.z;
//
//      }
//
        public sg_Transformation(sg_Vector3 n, sg_Vector3 cenPt)
        {
            sg_Vector3 newZ = new sg_Vector3(n);
            sg_Vector3 newX = new sg_Vector3(90, n.getDip() - 90);
            sg_Vector3 newY = newZ.crossMul(newX);

            newX.Normalize();
            newY.Normalize();
            newZ.Normalize();

            _r[0, 0] = newX.x; _r[0, 1] = newY.x; _r[0, 2] = newZ.x;
            _r[1, 0] = newX.y; _r[1, 1] = newY.y; _r[1, 2] = newZ.y;
            _r[2, 0] = newX.z; _r[2, 1] = newY.z; _r[2, 2] = newZ.z;

            _t[0] = cenPt.x; _t[1] = cenPt.y; _t[2] = cenPt.z;
        }
예제 #27
0
        public static SGBox3D operator +(SGBox3D box1, SGBox3D box2)
        {
            double minx = getmin(box1._pt1.x, box1._pt2.x, box2._pt1.x, box2._pt2.x);
            double maxx = getmax(box1._pt1.x, box1._pt2.x, box2._pt1.x, box2._pt2.x);

            double miny = getmin(box1._pt1.y, box1._pt2.y, box2._pt1.y, box2._pt2.y);
            double maxy = getmax(box1._pt1.y, box1._pt2.y, box2._pt1.y, box2._pt2.y);

            double minz = getmin(box1._pt1.z, box1._pt2.z, box2._pt1.z, box2._pt2.z);
            double maxz = getmax(box1._pt1.z, box1._pt2.z, box2._pt1.z, box2._pt2.z);

            sg_Vector3 pt1 = new sg_Vector3(minx, miny, minz);
            sg_Vector3 pt2 = new sg_Vector3(maxx, maxy, maxz);

            return(new SGBox3D(pt1, pt2));
        }
예제 #28
0
        public sg_Transformation(sg_Vector3 n1, sg_Vector3 n2, sg_Vector3 cenPt)
        {
            sg_Vector3 newZ = new sg_Vector3(n1);
            sg_Vector3 newY = newZ.crossMul(n2);
            sg_Vector3 newX = newY.crossMul(newZ);

            newX.Normalize();
            newY.Normalize();
            newZ.Normalize();

            _r[0, 0] = newX.x; _r[0, 1] = newY.x; _r[0, 2] = newZ.x;
            _r[1, 0] = newX.y; _r[1, 1] = newY.y; _r[1, 2] = newZ.y;
            _r[2, 0] = newX.z; _r[2, 1] = newY.z; _r[2, 2] = newZ.z;

            _t[0] = cenPt.x; _t[1] = cenPt.y; _t[2] = cenPt.z;
        }
예제 #29
0
        public static double getDip(sg_Vector3 v)
        {
            double a = getAngle(v);
            double l = v.length * Math.Sin(sg_math.AngleToArc(a));

            if (sg_math.isZero(l))
            {
                return(0.0);
            }
            double opp = v.x / l;

            if (opp > 1.0 || opp < -1.0)
            {
                opp = (int)(opp);
            }
            return(sg_math.ArcToAngle(Math.Asin(opp)));
        }
예제 #30
0
        public sg_plane(double angle, double dip)
        {
            certenPt = new sg_Vector3(0, 0, 0);

            Width  = -1;
            Height = -1;

            if (sg_math.isZero(angle))
            {
                __state = PlaneState.Horizon;
            }
            if (sg_math.isEquel(angle, 90))
            {
                __state = PlaneState.Vertical;
            }

            _v = new sg_Vector3(angle, dip);
        }