POV-Ray : Newsgroups : povray.advanced-users : Pointing at an object : Re: Pointing at an object Server Time
26 Jun 2024 09:02:03 EDT (-0400)
  Re: Pointing at an object  
From: Le Forgeron
Date: 15 Feb 2012 05:16:39
Message: <4f3b8607$1@news.povray.org>
Le 15/02/2012 10:15, Thomas de Groot a écrit :
> On 15-2-2012 5:01, Tail Kinker wrote:
>> Being dissatisfied with Point_At_Trans and Reorient_Trans, for use in my
>> inverse kinesics skeleton, I decided to break out the math and try to
>> write a replacement. And I ended up with this macro:
>>
>> #macro Point_To(tvector)
>> #declare rho = sqrt (
>> abs (tvector.x * tvector.x) +
>> abs (tvector.y * tvector.y) +
>> abs (tvector.z * tvector.z)
>> );
>> #declare sigma = sqrt (
>> abs (tvector.x * tvector.x) +
>> abs (tvector.y * tvector.y)
>> );
>> #declare phi = degrees(acos (tvector.z / rho));
>> #if (tvector.x < 0)
>> #declare theta = 180 - degrees(asin (tvector.y / sigma));
>> #else
>> #declare theta = degrees(asin (tvector.y / sigma));
>> #end
>> #if
>> <90 - phi, 0, theta - 90>
>> #end
>>
>> No doubt someone could make use of this. :)
> 
> That last #if is not correct. (...) and #end are missing...


While we are at it, #local would be safer than #declare.


Post a reply to this message

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