POV-Ray : Newsgroups : povray.advanced-users : Vector to Angle : Re: Vector to Angle Server Time
28 Apr 2024 18:23:02 EDT (-0400)
  Re: Vector to Angle  
From: dick balaska
Date: 16 Dec 2017 21:05:28
Message: <5a35d0e8$1@news.povray.org>
On 12/15/2017 07:50 AM, Bald Eagle wrote:
> dick balaska <dic### [at] buckosoftcom> wrote:
>> On 05/29/2017 03:42 PM, dick balaska wrote:
>>
>>   > Help, Math wizards, you're my only hope.
>>
>> I have started again to try to tackle this problem.
>>
>> Scott's solution gave me a vector, which is not what I need. :(  I need
>> an angle.
>>

http://www.buckosoft.com/tteoac/video/testRenders/test3.mp4

Eureka!

The solution is to rotate it with the Cartesian result and then 
translate it with scott's vcross-ish solution.  i.e.

object {
myCyl
#local flOfs = <-0.4,-0.3,0.7>; // flashlight offset from camera
rotate VtoA(Lookat-Camera)
translate Camera+ssOffset(flOfs)
}

// Convert this vector into its angle
#macro VtoA(V)
	#local _V=vnormalize(V);
	#local rZ=degrees(acos(_V.z));
	#local rY=0;
	#local rX=0;
	#if (_V.y != 0)
		#local rY=degrees(atan2(_V.x,_V.y));
	#else
		#local rX=rZ;
		#local rZ=0;
	#end
	<-rZ,rX,-rY>
#end


#macro ssOffset(bar)
	#local newZ = vnormalize( Lookat-Camera );
	#local newY = y;
	#local newX = vnormalize(vcross(newY,newZ));
	#local newY = vnormalize(vcross(newZ,newX));
	#local barOut = bar.x * newX + bar.y * newY + bar.z * newZ;
	barOut
#end


Post a reply to this message

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