Exemple #1
0
        public void SetNormalVector()
        {
            var a = _edges[0].FinishVertex - _edges[0].StartVertex;
            var b = _edges[3].StartVertex - _edges[3].FinishVertex;

            NormalVector = MatrixOperations.CrossProduct(a, b);
        }
 public static Vertex CrossProduct(Vertex a, Vertex b)
 {
     var x = new Vertex(a.Y*b.Z-a.Z*b.Y,
                           a.Z*b.X-b.Z*a.X,
                           a.X*b.Y-a.Y*b.X);
     x = NormalizeVector(x);
     return x;
 }
Exemple #3
0
 public Edge(Vertex start, Vertex finish)
 {
     _start = start;
     _finish = finish;
 }
 public static Vertex NormalizeVector(Vertex x)
 {
     var module = Math.Sqrt(x.X*x.X + x.Y*x.Y + x.Z*x.Z);
     return new Vertex(x.X/module, x.Y/module, x.Z/module);
 }
 public static double DotProduct(Vertex a, Vertex b)
 {
     return a.X*b.X + a.Y*b.Y + a.Z*b.Z;
 }
Exemple #6
0
        public double[,] GeraCubo()
        {
            var a = new Vertex(0, 0, 1);
            var b = new Vertex(1, 0, 1);
            var c = new Vertex(1, 1, 1);
            var d = new Vertex(0, 1, 1);
            var ee = new Vertex(0, 0, 0);
            var f = new Vertex(1, 0, 0);
            var g = new Vertex(1, 1, 0);
            var h = new Vertex(0, 1, 0);

            var A = new Edge(a, b);
            var B = new Edge(b, c);
            var C = new Edge(c, d);
            var D = new Edge(d, a);
            var E = new Edge(f, ee);
            var F = new Edge(ee, h);
            var G = new Edge(h, g);
            var H = new Edge(g, f);
            var I = new Edge(b, f);
            var J = new Edge(g, c);
            var K = new Edge(ee, a);
            var L = new Edge(d, h);

            var P1 = new Model.Polygon();
            P1.AddEdge(A);
            P1.AddEdge(B);
            P1.AddEdge(C);
            P1.AddEdge(D);
            P1.FaceNumber = 1;
            var P2 = new Model.Polygon();
            P2.AddEdge(C);
            P2.AddEdge(L);
            P2.AddEdge(G);
            P2.AddEdge(J);
            P2.FaceNumber = 2;
            var P3 = new Model.Polygon();
            P3.AddEdge(B);
            P3.AddEdge(J);
            P3.AddEdge(H);
            P3.AddEdge(I);
            P3.FaceNumber = 3;
            var P4 = new Model.Polygon();
            P4.AddEdge(D);
            P4.AddEdge(K);
            P4.AddEdge(F);
            P4.AddEdge(L);
            P4.FaceNumber = 4;
            var P5 = new Model.Polygon();
            P5.AddEdge(E);
            P5.AddEdge(I);
            P5.AddEdge(A);
            P5.AddEdge(K);
            P5.FaceNumber = 5;
            var P6 = new Model.Polygon();
            P6.AddEdge(H);
            P6.AddEdge(E);
            P6.AddEdge(F);
            P6.AddEdge(G);
            P6.FaceNumber = 6;

            var solid = new Solid();
            solid.addPolygon(P1);
            solid.addPolygon(P2);
            solid.addPolygon(P3);
            solid.addPolygon(P4);
            solid.addPolygon(P5);
            solid.addPolygon(P6);
            var x = solid.AsMatrix();
            return x;
        }