# Dot product strangeness

## Recommended Posts

Hi;

I have quite a simple question on a seemingly simple task, yet I'm kinda confused. If you check out the snapshot attached, you'll see that I tried to create Outward facing normals on a circle and also vectors facing along the positive Z axis in a parallel fashion. When I go ahead and get the dot product of these 2 vectors, I know I should get scalar values between -1 and 1. Yet, when you check out points 0, 2, 4 and 6, not all the values are as they should be. The dot product on points 0 and 4 seem to be correct, yet I'm getting off values for the other 2. What do you think I'm doing wrong?

Thank you so much in advance;

AJ

##### Share on other sites

Nothing wrong with the results (the small values near zero are due to the numerical accuracy)

##### Share on other sites

Hi @Aizatulin Thanx for your reply. The problem that I'm seeing is that the values go beyond -1 and 1. Shouldn't they yields be confined to that bracket only? And with both vectors normalized, I find the results to be off

Edited by noc2
##### Share on other sites

The values you outlined are not outside [-1, 1]. Some of them are just really small values.

##### Share on other sites

17 minutes ago, animatrix said:

The values you outlined are not outside [-1, 1]. Some of them are just really small values.

Oh jeez... Thanx @animatrix. So, I guess I'm add odds as to how to read those values. Lastly, I really want to be able to read those values correctly. So, the dot product at point #2 reads: 4.37114e-08 as is. I'm aware that it should be very closely biased toward 0 as the angle is seemingly almost 90 degrees between the 2 vectors. What is the right way to interpret such numeric yields, for someone like me, who expects to see literally something like -0.00001 or something?

Lotsa cheers;

AJ

##### Share on other sites

You can do something like this: if (abs(f@dot) < 1e-6){f@dot = 0;}

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×