ptransform vex function
Transforms a vector from one space to another.
vector ptransform(vector , matrix )vector ptransform(string tospace, vector v)Transforms from “space:current” (see below).
vector ptransform(string fromspace, string tospace, vector v)
The transform functions let you transform a vector from one space to another.
ptransform interprets the vector as a position.
vtransform interprets the vector as a direction vector, and so doesn’t apply the translations from the matrix.
ntransform interprets the vector as a normal vector, and so multiplies by the inverse transpose of the matrix (ignoring the translations).
The possible values for the space arguments are:
| An object path | Use the object space of an object specifed by a path string.
| ||
"space:object" | Object space of the current object. | ||
"space:world" | Houdini world space. | ||
"space:camera" | mantra camera space. | ||
"space:texture" | Space assigned to the current shader. | ||
"space:ndc" | Normal Device Coordinate space. | ||
"space:current" | The current space the vector is in. | ||
"space:world" | Houdini world space. |
The version with only a tospace argument assumes fromspace is “space:current”. For example:
Pworld = ptransform("space:world", P);
…is equivalent to:
Pworld = ptransform("space:current", "space:world", P);
Examples
Transform a vector from its current space to object space:
ospace = ptransform("space:object", P)
Transform a vector from object space to mantra’s natural coordinate space (“camera” space):
ospace = ptransform("space:object", "space:current", P)
