Exemplo n.º 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));
    }
Exemplo n.º 2
0
 public static ExpVector DirToFrom(this IPlane to, ExpVector pt, IPlane from)
 {
     return(to.DirToPlane(from.DirFromPlane(pt)));
 }