POV-Ray : Newsgroups : povray.advanced-users : Pointing at an object Server Time
23 Dec 2024 07:52:56 EST (-0500)
  Pointing at an object (Message 1 to 7 of 7)  
From: Tail Kinker
Subject: Pointing at an object
Date: 14 Feb 2012 23:01:39
Message: <4f3b2e23$1@news.povray.org>
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.  :)


Post a reply to this message

From: Le Forgeron
Subject: Re: Pointing at an object
Date: 15 Feb 2012 03:53:46
Message: <4f3b729a$1@news.povray.org>
Le 15/02/2012 05:01, Tail Kinker a écrit :
> No doubt someone could make use of this.


A bit of documentation might help.
Such as : the output is a vector for use with rotate, which will
transform the x direction into the a vector aligned with the parameter.
The other vectors of the base (y & z) are not constrained and might jump
when the parameter evolves (do not be surprised in animation!).

An input parameter of <0,0,0> is not supported and might stop your scene.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Pointing at an object
Date: 15 Feb 2012 04:15:06
Message: <4f3b779a$1@news.povray.org>
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...

Thomas


Post a reply to this message

From: Le Forgeron
Subject: Re: Pointing at an object
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

From: Tail Kinker
Subject: Re: Pointing at an object
Date: 15 Feb 2012 07:39:34
Message: <4f3ba786$1@news.povray.org>
On 12-02-15 05:16 AM, Le_Forgeron wrote:
> Le 15/02/2012 10:15, Thomas de Groot a écrit :

>> That last #if is not correct. (...) and #end are missing...
>
>
> While we are at it, #local would be safer than #declare.
>

I copied the macro out of the file I used to test it, not the version I 
saved.  In other words, the slightly erroneous one.  Yes, the last #if 
is superfluous and should be deleted.  In the version I saved, all the 
#declare had been changed to #local.  They were made #declare in the 
testing version in order to be able to read those variables outside the 
macro, for debugging purposes.

The output is a vector, to be used with rotate, that will align the 
object about the origin so that its y axis will now point towards 
tvector.  Jumps will occur when tvector.y = 0 and tvector.x crosses 0.

And yes, an input vector of 0 will break the macro.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Pointing at an object
Date: 15 Feb 2012 18:15:01
Message: <web.4f3c3bf38775ae27fb5881bf0@news.povray.org>
Tail Kinker <the### [at] gmailcom> 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.
......

Would you care to explain what problems you experience with those macros ?

--
Tor Olav
http://subcube.com


Post a reply to this message

From: Tail Kinker
Subject: Re: Pointing at an object
Date: 18 Feb 2012 20:15:54
Message: <4f404d4a$1@news.povray.org>
On 12-02-15 06:14 PM, Tor Olav Kristensen wrote:

> Would you care to explain what problems you experience with those macros ?
>

The biggest problem was that they tended to jump about as y approached 
zero for the target point.  For use in an IK skeleton, this was 
problematic.  Mine jumps as well, but along a different axis - y at 
zero, and as x approached zero.  This is better for an IK skeleton.


Post a reply to this message

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