dongju.jeong Posted January 10, 2019 Share Posted January 10, 2019 (edited) What does diffrent this function compare to the getAngle(vec3,vec3) function? Edited January 10, 2019 by dongju.jeong Link to comment
fox Posted January 10, 2019 Share Posted January 10, 2019 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! Link to comment
dongju.jeong Posted February 8, 2019 Author Share Posted February 8, 2019 What is the range of values returned by node->getRotation()->getAngle()?0~360 or -180~180? Link to comment
silent Posted February 8, 2019 Share Posted February 8, 2019 dongju.jeong Quote The result is within the [-180.0; 180.0] range for getAngle(v0, v1, up). The result is within the [0.0; 180.0] range for getAngle(v0,v1). How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
dongju.jeong Posted February 8, 2019 Author Share Posted February 8, 2019 (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 February 8, 2019 by dongju.jeong Link to comment
silent Posted February 8, 2019 Share Posted February 8, 2019 Result will be in the [-180.0;180.0] range for quat->getAnlge(). How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts