4.7.3 Geometric functions

distance( p1, p2)
Returns the distance between two points. The arguments should be of type vec3.

faceforward( N, I, Nref)
Flips N so that it faces in the direction opposite to I.

Note: In contrast to the Shading Language Nref is not optional.

length( v)
Returns the length of a vector. This is equivalent to calling v.length().

normalize( v)
Returns a unit vector in the direction of v. This is equivalent to calling v.normalize().

ptlined( p0, p1, q)
Returns the distance between point q and the line segment p0, p1. The arguments should be of type vec3.

reflect( I, N)
Returns the reflection vector given an incident direction I and a normal vector N. This is equivalent to calling I.reflect(N).

refract( I, N, eta)
Returns the transmitted vector given an incident direction I, the normal vector N and the relative index of refraction eta. This is equivalent to calling I.refract(N, eta).

xcomp( p)
Return the x component of p. This is equivalent to p.x.

ycomp( p)
Return the y component of p. This is equivalent to p.y.

zcomp( p)
Return the z component of p. This is equivalent to p.z.

setxcomp( p, x)
Set the x component of p. This is equivalent to p.x = x.

setycomp( p, y)
Set the y component of p. This is equivalent to p.y = y.

setzcomp( p, z)
Set the z component of p. This is equivalent to p.z = z.

comp( c, index)
Get an individual color component. This is equivalent to c[index].

setcomp( c, index, value)
Set an individual color component. This is equivalent to c[index] = value.