Beispiel #1
0
 public Int32 Add(Vertex vertex)
 {
     Int32 C = Count;
     Count++;
     m_Items[C] = vertex;
     return C;
 }
Beispiel #2
0
 public Vertex Proj2d(Vertex v)
 {
     double vx = (v.X - Point.X);
     double vy = (v.Y - Point.Y);
     double bq = (Direction.X * vx + Direction.Y * vy) / ((Direction.X * Direction.X) + (Direction.Y * Direction.Y));
     return new Vertex(Point.X + bq * Direction.X, Point.Y + bq * Direction.Y, Point.Z + bq * Direction.Z);
 }
Beispiel #3
0
 public Circle(Double radius, Int32 PointCount): base(PointCount)
 {
     m_Radius = radius;
     Double AngleStep = 2*Math.PI / PointCount;
     Double Angle = 0;
     for (Int32 i = 0; i < PointCount; i++)
     {
         this[i] = new Vertex(Radius * Math.Cos(Angle), Radius * Math.Sin(Angle));
         Angle += AngleStep;
     }
 }
Beispiel #4
0
 public Boolean Cross2d(Line L, ref Vertex Res)
 {
     Vertex d1 = new Vertex(Direction.X, Direction.Y);
     Vertex d2 = new Vertex(-L.Direction.X, -L.Direction.Y);
     Double Dv = d2.Y * d1.X - d2.X * d1.Y;
     if (Math.Abs(Dv) < Eps * Eps) return false;
     Double Ml = (d2.Y * (L.Point.X - Point.X) - d2.X * (L.Point.Y - Point.Y)) / Dv;
     Res = new Vertex();
     Res.X = Point.X + d1.X * Ml;
     Res.Y = Point.Y + d1.Y * Ml;
     Res.Z = Point.Z + Direction.Z * Ml;
     return true;
 }
Beispiel #5
0
 public Vertex RotateZ(Double Angle)
 { 
     Double S = Math.Sin(Angle);
     Double C = Math.Cos(Angle);
     Vertex Result = new Vertex();  
     Result.X =  X * C + Y * S;
     Result.Y = -X * S + Y * C;
     Result.Z =  Z;
     return Result;
 }
Beispiel #6
0
 public Double LengthTo(Vertex V)
 {
     return (this - V).Length();
 }
Beispiel #7
0
        //опрераторы

        public Boolean Equal(Vertex V)
        { 
            Double eps = 0.01;
            return ((Math.Abs(X - V.X)<eps)&((Math.Abs(Y - V.Y)<eps)));
        }
Beispiel #8
0
 public Vertexes Offset(Double Dist)
 {
     Vertexes Result = new Vertexes();
     Line PrevLine = null;
     for (Int32 i = 0; i < Count; i++)
     {
         Line Line = null;
         if (i == Count - 1)
         {
             Vertex Vector = (this[i] - this[i-1]).Normalize();
             Vector = Vector.RotateZ(Math.PI / 2) * Dist;
             Result.Add(this[i] + Vector);
             break;
         }
         if (i == 0)
         {
             Vertex Vector = (this[i + 1] - this[i]).Normalize();
             Vector = Vector.RotateZ(Math.PI/2) * Dist;
             Result.Add(this[i] + Vector);
             Line = new Line((this[i + 1] - this[i]).Normalize(), this[i] + Vector);
         }
         else
         {
             Vertex Vector = (this[i + 1] - this[i]).Normalize();
             Vector = Vector.RotateZ(Math.PI / 2) * Dist;
             Line = new Line((this[i + 1] - this[i]).Normalize(), this[i] + Vector);
             Vertex point = new Vertex();
             if (Line.Cross2d(PrevLine, ref point))
             {
                 Result.Add(point);
             }
         }
         PrevLine = new Line(Line.Direction, Line.Point);
     }
     return Result;
 }
Beispiel #9
0
 public Line(Vertex direction, Vertex point)
 {
     Direction = direction;
     Point = point;
 }
Beispiel #10
0
 public Rect(Vertex a, Vertex b)
 {
     A = a;
     B = b;
 }
Beispiel #11
0
 public Boolean VertexIn(Vertex V)
 {
     return ((A.X <= V.X) & (B.X >= V.X) & (A.Y >= V.Y) & (B.Y <= V.Y));
 }