hi, first post in a loooong time :) please go easy :)

i've started off with a cube like arena with some random dots along the walls.
i then went and found the normal of each dot.

i'd like to filter out the normals somehow and i started this by using the law of cosines and the dot product. -- http://en.wikipedia.org/wiki/Dot_product

the problem is that although most of the normals on the floor are remaining, there are still many normals on the walls and i cannot for the life of me understand why? i specifically stated to only include those between 80 and 100 degrees (or equivalent in radians).

i use the x-y plane (1, 0, 0) and the normal (nx, ny, nz) in the equation.

i'm doing this all in c++.

any help here would be much appreciated, thanks!

A normal is a vector and the dot product returns a scalar.

To calculate the normal of a plane when you know two vectors along that plane then you use the cross product (because it gives a vector perpendicular to the plane aka the normal).

The equation of a plane (in Cartesian coordinates) is Ax + By + Cz = D, since the x-axis vector is (1,0,0) and the y-axis vector is (0,1,0) when 'crossed' these vectors that represent the x-y plane make a vector normal to the plane that is (0,0,1) which is the z-axis. The A, B and C coefficients of a plane are the x, y, z values of the vector normal to it (meaning A = 0, B = 0, C = 1 for the x-y plane). And since the origin (0,0,0) is on the x-y plane you can substitute those x, y, z values into the x-y plane equation and you get z = 0 for the equation of the x-y plane (meaning any point with a z value of 0 will be on the x-y plane).

I am not sure what you mean by only including dots that have normals with angles of 80 to 100 degrees because the definition of a vector normal to a plane is one that is perpendicular (90 degrees) to it.

Can you post some code or a screenshot to see what is going on because I am having a hard time understanding what you mean by dots on the walls.

Here are two functions I threw together that you can use
Where V3 is just a class/structure that has x, y, z member variables in it.

``````V3 CrossProduct( V3 v1, V3 v2 )
{
V3 vr;
vr.x = v1.y*v2.z - v1.z*v2.y;
vr.y = v1.z*v2.x - v1.x*v2.z;
vr.z = v1.x*v2.y - v1.y*v2.x;

return vr;
}

double DotProduct( V3 v1, V3 v2 )
{
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.