Esempio n. 1
0
 public VsSegment(Segment3D s, Color c)
 {
     type   = "VsSegment";
     col    = c;
     colPen = new Pen(col);
     seg    = s;
 }
Esempio n. 2
0
 public VsSegment(Vector3D p0, Vector3D p1, Color c)
 {
     type   = "VsSegment";
     col    = c;
     colPen = new Pen(col);
     seg    = new Segment3D(p0, p1);
 }
Esempio n. 3
0
 public VsSegment()
 {
     type   = "VsSegment";
     col    = Color.Black;
     colPen = new Pen(col);
     seg    = new Segment3D();
 }
Esempio n. 4
0
 public VsSegment(double x0, double y0, double z0, double x1, double y1,
                  double z1, Color c)
 {
     type   = "VsSegment";
     col    = c;
     colPen = new Pen(col);
     seg    = new Segment3D(x0, y0, z0, x1, y1, z1);
 }
Esempio n. 5
0
 public VsSegment(double x0, double y0, double z0, double x1, double y1,
                  double z1, int r, int g, int b)
 {
     type   = "VsSegment";
     col    = Color.FromArgb(r, g, b);
     colPen = new Pen(col);
     seg    = new Segment3D(x0, y0, z0, x1, y1, z1);
 }
Esempio n. 6
0
        public Segment3D Vs_line_clip_3df(Segment3D seg)
        {
            double    xs  = seg.p0.x;
            double    ys  = seg.p0.y;
            double    zs  = seg.p0.z;
            double    xe  = seg.p1.x;
            double    ye  = seg.p1.y;
            double    ze  = seg.p1.z;
            Segment3D ret = new Segment3D();
            double    x0;
            double    y0;
            double    z0;
            double    x1;
            double    y1;
            double    z1;

            if (zs <= ze)
            {
                x0 = xs;
                y0 = ys;
                z0 = zs;
                x1 = xe;
                y1 = ye;
                z1 = ze;
            }
            else
            {
                x0 = xe;
                y0 = ye;
                z0 = ze;
                x1 = xs;
                y1 = ys;
                z1 = zs;
            }
            if (z1 < 0.10000000000000001D)
            {
                return(null);
            }
            if (z0 >= 0.10000000000000001D)
            {
                ret.SetP0(new Vector3D(seg.p0));
                ret.SetP1(new Vector3D(seg.p1));
                return(ret);
            }
            else
            {
                double t = (0.10000000000000001D - z0) / (z1 - z0);
                x0 += t * (x1 - x0);
                y0 += t * (y1 - y0);
                z0  = 0.10000000000000001D;
                ret.SetP0(new Vector3D(x0, y0, z0));
                ret.SetP1(new Vector3D(x1, y1, z1));
                return(ret);
            }
        }
Esempio n. 7
0
 public VsSegment(VsSegment s)
 {
     type   = "VsSegment";
     col    = s.col;
     colPen = new Pen(col);
     if (s.seg != null)
     {
         seg = new Segment3D(s.seg);
     }
     else
     {
         seg = null;
     }
 }
Esempio n. 8
0
        public Segment3D Vs_line_clip_2d(Segment3D org)
        {
            Segment3D ret = new Segment3D();
            double    y;
            double    x   = y = 0.0D;
            double    cx1 = vp_xmin - 0.4D;
            double    cy1 = vp_ymin - 0.4D;
            double    cx2 = vp_xmax + 0.4D;
            double    cy2 = vp_ymax + 0.4D;
            double    x1  = org.p0.x;
            double    y1  = org.p0.y;
            double    x2  = org.p1.x;
            double    y2  = org.p1.y;
            int       c1  = Make_4bit_code(x1, y1, cx1, cy1, cx2, cy2);
            int       c2  = Make_4bit_code(x2, y2, cx1, cy1, cx2, cy2);

            for (int i = 0; i < 100; i++)
            {
                if ((c1 | c2) == 0)
                {
                    ret.p0.x = x1;
                    ret.p0.y = y1;
                    ret.p0.z = 0.0D;
                    ret.p1.x = x2;
                    ret.p1.y = y2;
                    ret.p1.z = 0.0D;
                    return(ret);
                }
                if ((c1 & c2) != 0)
                {
                    return(null);
                }
                int c;
                if (c1 != 0)
                {
                    c = c1;
                }
                else
                {
                    c = c2;
                }
                if (x1 == x2)
                {
                    if (y2 < cy1)
                    {
                        y = cy1;
                    }
                    else if (y2 > cy2)
                    {
                        y = cy2;
                    }
                    if (y1 < cy1)
                    {
                        y = cy1;
                    }
                    else if (y1 > cy2)
                    {
                        y = cy2;
                    }
                    x = x1;
                }
                else if ((c & 1) != 0)
                {
                    y = y1 + ((y2 - y1) * (cx1 - x1)) / (x2 - x1);
                    x = cx1;
                }
                else if ((c & 2) != 0)
                {
                    y = y1 + ((y2 - y1) * (cx2 - x1)) / (x2 - x1);
                    x = cx2;
                }
                else if (y1 == y2)
                {
                    if (x2 < cx1)
                    {
                        x = cx1;
                    }
                    else if (x2 > cx2)
                    {
                        x = cx2;
                    }
                    if (x1 < cx1)
                    {
                        x = cx1;
                    }
                    else if (x1 > cx2)
                    {
                        x = cx2;
                    }
                    y = y1;
                }
                else if ((c & 4) != 0)
                {
                    x = x1 + ((x2 - x1) * (cy1 - y1)) / (y2 - y1);
                    y = cy1;
                }
                else if ((c & 8) != 0)
                {
                    x = x1 + ((x2 - x1) * (cy2 - y1)) / (y2 - y1);
                    y = cy2;
                }
                if (c == c1)
                {
                    x1 = x;
                    y1 = y;
                    c1 = Make_4bit_code(x, y, cx1, cy1, cx2, cy2);
                }
                else
                {
                    x2 = x;
                    y2 = y;
                    c2 = Make_4bit_code(x, y, cx1, cy1, cx2, cy2);
                }
            }

            return(null);
        }
Esempio n. 9
0
        public Segment3D Project(Projector proj)
        {
            Segment3D ret = new Segment3D(proj.Project(p0), proj.Project(p1));

            return(ret);
        }
Esempio n. 10
0
 public Segment3D(Segment3D seg)
 {
     p0 = new Vector3D(seg.p0);
     p1 = new Vector3D(seg.p1);
 }