Ejemplo n.º 1
0
        public double ParameterAtPoint(Triple pt)
        {
            Triple v = this.Direction;
            Triple u = this.StartPoint - pt;
            var    t = -1 * v.Dot(u) / v.Dot(v);

            return(t);
        }
Ejemplo n.º 2
0
 internal bool isPlanar(List <Line> lines, out Triple currentNormal)
 {
     currentNormal = lines[0].Direction.Cross(lines[1].Direction).Normalized();
     for (int i = 1; i < lines.Count - 1; i++)
     {
         var nextNormal = lines[i].Direction.Cross(lines[i + 1].Direction).Normalized();
         if (!(Math.Abs(currentNormal.Dot(nextNormal)) > 1 - Tolerance))
         {
             return(false);
         }
         currentNormal = nextNormal;
     }
     return(true);
 }
Ejemplo n.º 3
0
        public Triple Rotate(Triple axis, float angle, Triple origin = null)
        {
            if (origin == null)
            {
                origin = new Triple(0, 0, 0);
            }
            Triple z = axis.Normalized();
            Triple x = z.GeneratePerpendicular().Normalized();
            Triple y = z.Cross(x).Normalized();

            Triple v = this - origin;

            double vx = x.Dot(v);
            double vy = y.Dot(v);
            double vz = z.Dot(v);

            double sin = Math.Sin(angle);
            double cos = Math.Cos(angle);

            double vx_ = cos * vx - sin * vy;
            double vy_ = sin * vx + cos * vy;

            return(origin + x * vx_ + y * vy_ + z * vz);
        }