EDIT UPDATE(adsbygoogle = window.adsbygoogle || []).push({});

so basically I figured this out. it was apparently what i was rotating around.

Now i can rotate much mroe finely I'm not sure how to close this though so i'm just adding this here

this has to with a programming problem where i am rotating an object so it snaps into alignment with the face of another object.

because i've been told arctangent2 is more accurate (for vectors near parallel)

and my issue is near parallel vectors i'm using that

basically i take the crossproduct of the normal and the inverse normal of 2 planes

to find the axis

(vectors 1 and 2 are normalized, atan apparently doesnt care but they are because

they come spat out that way)

vector1 = normal of plane were rotating

vector2 = normal of plane were rotating to

axis = vector1 * -vector2

that should give me the axis to from from 1 to 2

then the angle i have as

y = magnitude of axis

x = dot product of (vector1, -vector2)

angle = arctangent2(y,x)

is there any way to make this more accurate though maybe squaring or something

basically the issue is that if the dot product is like .99999999

and the magnitude of the axis is like .01

i end up through inprecision flipping back and forth I guess

(my axis goes from 0,0,.7 to 0,0,-.7) for example

which I think whats happening is i'm rotating just a bit too far, then needing to rotate the opposite way back but going a bit to far.

currently using that I can get to within about .1radians or 5 degrees of accuracy. (that is i basically tell it if the angle is less than .1 radians to call that parallel and not rotate, it's close enough, otherwise i have this vibrating effect as the object constantly rotates quickly back and forth a few degrees).

That actually seems quite large to me for a floating point number and im wondering if perhaps i'm doing this wrong.

Also I can use quanternions

i've been told that a quanternion can be made by going

quanternion x,y,z = cross product of vectors

w = 1 + dot product of vectors (basically nearly there it'd be 1.999999999)

But i dont get quanternions at all so i'm not sure if thats accurate

also not sure if thats like basically how much I would add

like current quanternion rotation + the calculate rotation

or

current quan rotation just equals calculated

lastly im not sure if what point i rotate around matters

thats is

right now if i have a box right I rotate around the magical point in the middle of the square by angle degrees around axis

should i in fact rotate teh object as it were around the point in the mdidle of whatever plane on the side of the box was hit?

basically i'm worried that rotating around the center of the cube is actually moving the plane itself and is part of the reason for my lack of accuracy.

I'm having trouble visualizing the differences in my head though so im not sure.

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Angle between 2 vectors. accuracy

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**