POV-Ray : Newsgroups : povray.general : Inverse of vrotate? : Re: Inverse of vrotate? Server Time
12 Jul 2025 17:42:23 EDT (-0400)
  Re: Inverse of vrotate?  
From: Mike Horvath
Date: 11 Mar 2018 01:16:09
Message: <5aa4c9a9$1@news.povray.org>
I forgot I did this once already.

Mike




#macro vanglesXY(tVec2)
	#local fSgnX = 1;
	#local fSgnY = 1;
	#local tPrjB1 = vnormalize(<tVec2.x, 0, tVec2.z>);

	#if (tPrjB1.x != 0)
		#local fSgnX = tPrjB1.x/abs(tPrjB1.x) * -1;
	#end

	#local tPrjB1 = <tPrjB1.x, tPrjB1.y, max(min(tPrjB1.z,1),-1)>;
	#local fAngY = acosd(tPrjB1.z) * fSgnX;
	#local tPrjB2 = vnormalize(vrotate(tVec2, <0, fAngY, 0>));

	#if (tPrjB2.y != 0)
		#local fSgnY = tPrjB2.y/abs(tPrjB2.y);
	#end

	#local tPrjB2 = <tPrjB2.x, tPrjB2.y, max(min(tPrjB2.z,1),-1)>;
	#local fAngX = acosd(tPrjB2.z) * fSgnY;
	<fAngX, (fAngY + 180) * -1, 0>
#end


Post a reply to this message

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