POV-Ray : Newsgroups : povray.newusers : How to rotate a declared object using normal? : How to rotate a declared object using normal? Server Time
30 Jul 2024 00:28:30 EDT (-0400)
  How to rotate a declared object using normal?  
From: Tranceaholic
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

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