Example #1
0
 public override void HandleRotationChanged(double angleX, double angleY)
 {
     var a = new Vec3(0,0,0);
     var b = new Vec3(0,0,1);
     foreach(var f in this.model.Faces){
         var n = f.GetNormal();
         LinearAlgebra.PlaneVectorIntersection(a, b, n, f.GetVertexPositions().First());
     }
     base.HandleRotationChanged(angleX, angleY);
 }
Example #2
0
 private void setSliderValue(double val)
 {
     this.toRender = this.modelClone.Clone();
     this.faceToElevate = this.toRender.Faces.First();
     this.faceCenter = this.toRender.GetFaceCenter(this.faceToElevate);
     this.toRender.RemoveFace(this.faceToElevate);
     Vec3 newVertex = this.faceCenter.Extend(val);
     var faceVertexIndices = this.faceToElevate.GetVertexIndices();
     int ct = faceVertexIndices.Count;
     for (int i = 0; i < ct; i++) {
         int idx1 = faceVertexIndices[i];
         int idx2 = faceVertexIndices[(i + 1) % ct];
         int vIndex = this.toRender.AddVertex(newVertex);
         this.toRender.AddFace(idx1, idx2, vIndex);
         this.toRender.AddFace(vIndex, idx2, idx1);
     }
     //Get the center of the face
     //Determine the new vertex position
     //Add n new triangular faces
     //remove the old face
 }
Example #3
0
 public int AddVertex(Vec3 newVertex)
 {
     this.vertices.Add(newVertex);
     return this.vertices.Count - 1;
 }
Example #4
0
 internal double DotProduct(Vec3 vec3)
 {
     return this.X * vec3.X + this.Y * vec3.Y + this.Z * vec3.Z;
 }
Example #5
0
 internal double Dist(Vec3 b)
 {
     return Math.Sqrt((b.X - this.X).Sqrd() + (b.Y - this.Y).Sqrd());
 }
Example #6
0
 internal Vec3 CrossProduct(Vec3 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 Vec3(x, y, z);
 }
Example #7
0
 internal double Dist(Vec3 b)
 {
     return(Math.Sqrt((b.X - this.X).Sqrd() + (b.Y - this.Y).Sqrd()));
 }
Example #8
0
 internal double DotProduct(Vec3 vec3)
 {
     return(this.X * vec3.X + this.Y * vec3.Y + this.Z * vec3.Z);
 }
Example #9
0
        public static SegmentPlaneIntersection PlaneVectorIntersection(Vec3 a, Vec3 b, Vec3 planeNormal, Vec3 planePoint)
        {
            Vec3   u = b - a;
            Vec3   w = a - planePoint;
            double D = planeNormal.DotProduct(u);
            double N = -planeNormal.DotProduct(w);

            if (Math.Abs(D) < EPS)
            {
                if (N == 0)
                {
                    return(SegmentPlaneIntersection.SegmentLiesInPlane);
                }
                else
                {
                    return(SegmentPlaneIntersection.NoIntersection);
                }
            }
            double sI = N / D;

            if (sI < 0 || sI > 1)
            {
                return(SegmentPlaneIntersection.NoIntersection);
            }
            return(SegmentPlaneIntersection.Intersection);
        }