Topic: What's wrong with this rotation? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=27850" title="Pages that link to Topic: What&amp;#039;s wrong with this rotation? (Page 1 of 1)" rel="nofollow" >Topic: What&#039;s wrong with this rotation? <span class="small">(Page 1 of 1)</span>\

 
_Mauro
Maniac (V) Inmate

From:
Insane since: Jul 2005

posted posted 04-28-2006 01:04

Hello world.
It's getting late and I finally managed to get a quick bugfix for an OpenGL issue.
Basically, I have two vectors in 3d space, and the angle between them should tend towards 0.

It tends to that in most cases, but in some, it tends towards "minus infinity", and this is the limit of my bugfix: I can't seem to be able to get rid of.. wait a minute, just had an idea about the cause.
Anyway, I figured I'd post the code which sometimes returns minus infinity.

It shouldn't, unless I've forgot something about the acos function in maths...

(scratches head... shouldn't do maths at 1AM I guess, but hey..)

code:
GLfloat vectorMaths::angleBetween(vertex * v1, vertex * v2){
	GLfloat dotprod = v1->x*v2->x+v1->y*v2->y+v1->z*v2->z;
	return (GLfloat)acos(dotprod / (length(v1) * length(v2)));
}



(Edited by _Mauro on 04-28-2006 01:11)



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu