Jump to content

getAngle function


photo

Recommended Posts

Posted (edited)

What does diffrent this function compare to the getAngle(vec3,vec3) function?

image.png.b1bf3013a74ce2f40e9ba734a3af4004.png

Edited by dongju.jeong
Posted

Hi Dongju,

As written in the docs,  the getAngle(v0,v1) function returns an unsigned acute angle between the two vectors (the smaller of the two possible angles). The result is within the [0.0; 180.0] range.

While the getAngle(v0, v1, up) function returns a signed angle relative to the up vector specified. The result is within the [-180.0; 180.0] range.

float getAngle(const vec3 &v0, const vec3 &v1)
{
	float d = dot(v0, v1) / (length(v0) * length(v1));
	return acos(clamp(d, -1.0f, 1.0f)) * RAD2DEG;
}

float getAngle(const vec3 &v0, const vec3 &v1, const vec3 &up)
{
	vec3 n = cross(v0, v1);
	return atan2(dot(normalize(up), n), dot(v0, v1)) * RAD2DEG;
}

Thank you!

  • 4 weeks later...
Posted

What is the range of values returned by node->getRotation()->getAngle()?

0~360 or -180~180?

Posted (edited)

I want value of range about quat->getangle() not Math's getAngle().

quat->getAngle() range is 0~180 too???

 

I checked with Log, it looks like -180~180. 
Thank you for your answers.

Edited by dongju.jeong
×
×
  • Create New...