POV-Ray : Newsgroups : povray.newusers : How to rotate a declared object using normal? Server Time
30 Jul 2024 02:22:56 EDT (-0400)
  How to rotate a declared object using normal? (Message 1 to 3 of 3)  
From: Tranceaholic
Subject: How to rotate a declared object using normal?
Date: 9 Jan 2005 16:45:01
Message: <web.41e1a5142d0a0d53b3941e880@news.povray.org>
I've just started experimenting with the Trace() function, and I need to
know if it is possible to use the normal returned to rotate an object that
was already declared. I tried to do this:

// Trace object Spike onto object Ball's surface.
#declare Norm = <0, 0, 0>;
#declare Start = <-8, 20, 0>;
#declare Inter = trace (Ball, Start, -y, Norm);
#if (vlength (Norm))
  object { Spike rotate Norm translate Inter }
#end

The spike is translated to the correct position, but it is not rotated; it
still points straight up.  So how would I use the returned normal to rotate
the spike so it points the same direction as the surface normal at Inter?

Here's the entire scene file:

// Test scene file.

#include "shapes.inc"
#include "colors.inc"

// Objects
--------------------------------------------------------------------

#declare Ball =
object {
  sphere { 0, 10 }
  texture {
    pigment { color Blue }
    finish { ambient 0.5 phong 1 }
  }
}

#declare Spike =
object {
  cone { <0, 0, 0>,0.5, <0, 1, 0>, 0 }
  texture {
    pigment { color Red }
    finish { ambient 0.5 phong 1 }
  }
}

// Scene
----------------------------------------------------------------------

camera {
  location <0, 20, -20>
  look_at <0, 0, 0>
}

light_source { <3000, 10000, 5000> color White }

object { Ball }

// Trace object Spike onto object Ball's surface.
#declare Norm = <0, 0, 0>;
#declare Start = <-8, 20, 0>;
#declare Inter = trace (Ball, Start, -y, Norm);
#if (vlength (Norm))
  object { Spike rotate Norm translate Inter }
#end


Post a reply to this message

From: Slime
Subject: Re: How to rotate a declared object using normal?
Date: 9 Jan 2005 17:03:07
Message: <41e1aa1b@news.povray.org>
> I've just started experimenting with the Trace() function, and I need to
> know if it is possible to use the normal returned to rotate an object that
> was already declared.

Use the Reorient_Trans macro in transforms.inc.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Tranceaholic
Subject: Re: How to rotate a declared object using normal?
Date: 9 Jan 2005 17:35:00
Message: <web.41e1b066227c4738b3941e880@news.povray.org>
"Slime" <fak### [at] emailaddress> wrote:
> > I've just started experimenting with the Trace() function, and I need to
> > know if it is possible to use the normal returned to rotate an object that
> > was already declared.
>
> Use the Reorient_Trans macro in transforms.inc.
>
>  - Slime
>  [ http://www.slimeland.com/ ]

Thanks for the quick response, Slime!  Using Reorient_Trans(y, Norm) gave
the result I was looking for!

Tranceaholic


Post a reply to this message

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