POV-Ray : Newsgroups : povray.advanced-users : Pointing at an object : Pointing at an object Server Time
26 Jun 2024 09:12:29 EDT (-0400)
  Pointing at an object  
From: Tail Kinker
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

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