]>
Dogcows Code - chaz/rasterize/blob - plane.hh
3 * CS5600 University of Utah
5 * mcgarvey@eng.utah.edu
18 * A class for a plane object.
20 class plane
: public element
27 plane(vec_t n
, scal_t d
) :
31 plane(vec_t p
, vec_t n
) :
32 norm(vec_normalize(n
)), dist(-vec_dot(norm
, p
))
35 plane(vec_t a
, vec_t b
, vec_t c
) :
36 norm(vec_normalize(vec_cross(vec_sub(b
, a
), vec_sub(c
, a
)))),
37 dist(-vec_dot(norm
, a
))
44 * Get the normal vector of the plane.
51 virtual bool intersect(ray_t ray
, contact_t
& hit
) const
53 scal_t denom
= vec_dot(ray
.d
, norm
);
55 // check for parallel condition
56 if (denom
== S(0.0)) {
57 if (scal_isequal(vec_dot(ray
.o
, norm
), -dist
)) {
61 return true; // the ray lies on the plane
63 return false; // no solution
66 scal_t numer
= vec_dot(ray
.o
, norm
) + dist
;
67 hit
.d
= -numer
/ denom
;
72 hit
.p
= ray_solve(ray
, hit
.d
);
73 if (S(0.0) <= numer
) {
77 hit
.n
= vec_neg(norm
);
82 virtual vec_t
txcoord(vec_t point
) const
88 uv
.x
= point
.x
- scal_floor(point
.x
);
89 uv
.y
= point
.z
- scal_floor(point
.z
);
97 * Destroy a new'd plane, releasing its memory.
100 void plane_destroy(plane
* p
)
This page took 0.03713 seconds and 4 git commands to generate.