Пример #1
0
    public static ExpVector NormalAtInPlane(this IEntity self, Exp t, IPlane plane)
    {
        if (self.plane != null)
        {
            var tang = self.TangentAt(t);
            if (tang == null)
            {
                return(null);
            }
            var n = ExpVector.Cross(tang, Vector3.forward);
            if (plane == self.plane)
            {
                return(n);
            }
            return(plane.DirToFrom(n, self.plane));
        }

        Param p      = new Param("pOn");
        var   pt     = self.PointOn(p);
        var   result = new ExpVector(pt.x.Deriv(p).Deriv(p), pt.y.Deriv(p).Deriv(p), pt.z.Deriv(p).Deriv(p));

        result.x.Substitute(p, t);
        result.y.Substitute(p, t);
        result.z.Substitute(p, t);
        if (plane == null)
        {
            return(result);
        }
        return(plane.DirToPlane(result));
    }
Пример #2
0
 public static ExpVector TangentAtInPlane(this IEntity entity, Exp t, IPlane plane)
 {
     if (plane == entity.plane)
     {
         return(entity.TangentAt(t));
     }
     return(plane.DirToFrom(entity.TangentAt(t), entity.plane));
 }