Degree to Rotation in an expression.

Discussions concerning programming of SOFTIMAGE©
Kel Solaar
Posts: 19
Joined: 29 Nov 2012, 08:13

Degree to Rotation in an expression.

Post by Kel Solaar » 16 Jan 2013, 21:05

Hello!

I'm trying to find a way to link an object axis rotation to some parameters of a shader: Basically I would like to drive a VRay shader VRayEnvImage.fhrotation ( Ranging from 0 to 360 ) to the Y rotation of an object ( Ranging from minus a lot to a lot :). At some point the object can have a rotation of -457 degrees, I need to fit that in range from 0 to 360 dynamically through an expression.

In Python I would do that:

Code: Select all

def degreeToRotation(value):
	rotation = value
	while rotation >= 360:
		rotation -= 360
	while rotation < 0:
		rotation += 360
	return rotation
	
print degreeToRotation(-1620)
Some help would be much appreciated!

Cheers,

KS

User avatar
Hirazi Blue
Administrator
Posts: 5113
Joined: 04 Jun 2009, 10:15

Re: Degree to Rotation in an expression.

Post by Hirazi Blue » 16 Jan 2013, 21:25

Could be that I am misunderstanding the question, but wouldn't a simple
"fmod(<val1>,<val2>)" (modulo operation) suffice, where <val2> equals 360 (or maybe 360.0)?
Stay safe, sane & healthy!

Kel Solaar
Posts: 19
Joined: 29 Nov 2012, 08:13

Re: Degree to Rotation in an expression.

Post by Kel Solaar » 16 Jan 2013, 21:34

Hirazi Blue wrote:Could be that I am misunderstanding the question, but wouldn't a simple
"fmod(<val1>,<val2>)" (modulo operation) suffice, where <val2> equals 360 (or maybe 360.0)?
Hi Hirazi!

You know there are moments in life when you feel stupid, well that's one of those, dunno where to hide really :)

Cheers mate :)

Code: Select all

def degreeToRotation(value):
	return value % 360
KS