POV-Ray : Newsgroups : povray.general : Trace(): help required : Re: Trace(): help required Server Time
1 Aug 2024 08:17:28 EDT (-0400)
  Re: Trace(): help required  
From: Kenneth
Date: 22 May 2006 02:45:00
Message: <web.44715ba0501983a81bc008390@news.povray.org>
"Sven Littkowski" <sve### [at] jamaica-focuscom> wrote:

> That means, the norm function actually could be used like a rotate < x, y, z
>  > command? And if so, where would be the point of rotation - would that
> point be the point where the placable object hits via the trace command the
> surface of the traced object, or would it be the placable objects natural
> postion from its own X,Y,Z coordinates (as usual, otherwise)?

Using the normal to try and rotate other already-created objects is not an
easy thing to accomplish.  True, it can be used quite well the way Warp has
shown, when actually CREATING an object at the traced intersection point.
But the results of doing something like, say,

object{my_small_object
 rotate my_norm*90 // to try and re-orient your small placed
                  // object according to the
                  // normal of the surface
 translate traced_intersection_point // putting each small object onto the
                                     // bigger traced object
            }

doesn't work out the way you might think. It *looks* like it works, sort of,
but the rotational results are not correct. I personally tried all sorts of
trigonometric trickery with the normal, and finally found a way to do this
(see below.)  But then I discovered the Point_At_Trans macro in
transforms.inc. With it, you can take any pre-created object -- made at the
origin--and rotate it using the my_norm vector. (It takes the +y vector
there and rotates it--and the object-- around to the my_norm vector.) Very
handy!!

My other way of doing it is this (using "dot notation" to pull out
individual vector values):
#declare x_degrees_reorient = degrees (atan2 (my_norm.y, my_norm.z));
#declare y_degrees_reorient = degrees (atan2 (my_norm.y, my_norm.x));

then rotate your pre-created object , while it's still at the origin, like
this:
rotate <90 - x_degrees_reorient, 0, z_degrees_reorient - 90)

then translate it to the traced location.

I can't guarantee that it has the EXACT same results as Point_At_Trans, but
it looks identical to me.

Ken W.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.