|
![](/i/fill.gif) |
I was implementing a cylinder primitive to my little pet project, a
raytracer, when I run into some problems.
The cylinder is defined the same way as in POV, by two vectors and a float,
representing the base and apex points and the radius, respectively. Writing
an intersection finder and other needed stuff for such a general case would
be rather difficult, so I reasoned that it would be easiest (and perhaps
most efficient, too?) to make the cylinder always lie along a coordinate
axis (say, the Y axis) in object space, and then provide an appropriate
transformation from object space to world space.
The problem is, how would I go about constructing such a transformation? I
took a look at the relevant part of the POV source code, but didn't quite
figure out how it does the trick. I could of course just grab the code, but
I'd rather understand the algorithm behind it.
I'd also like some insight into how to invert a transformation (4x4) matrix.
I did a bit googling but didn't come by anything too relevant.
Thanks in advance,
-Johannes
Post a reply to this message
|
![](/i/fill.gif) |