Archived

This topic is now archived and is closed to further replies.

normals

This topic is 6969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Surely if you just want to draw the normal along with the polygon you could generate a start point from the centre point of the polygon (all the points positions averaged), then normalise the normal (if you haven't already) and generate an end point for the line from the normals vector.
i.e.
vx = vy = yz = 0;
for(i=0;i{
vx+=poly.x;
vy+=poly.y;
vz+=poly.z;
}
vx/=poly.num_points;
vy/=poly.num_points;
vz/=poly.num_points;
start.x = vx;
start.y = vy;
start.z = vy;
end.x = vx + poly.normal.x * length;
end.y = vy + poly.normal.y * length;
end.z = vz + poly.normal.z * length;
Then perspective project this line into 2D and plot it.

Share on other sites
Thanks Mike.

I understand completely what you said, however, I think I might have been unclear in my original question.

I could find the points along the line normal to the polygon and then prespective project those points from 3D to 2D. This however, would require a divide for each point along the line normal to the polygon. This is the problem I want to avoid. I don't want the extra divides.

The equations I use for perspective projection are x'=(focus*x)/z and y'=(focus*y)/z, where focus is the focal length.

I've contemplated just projecting the normal along with the polygon, but then what do you do when the normal is <1,0,0>. Won't you get a divide-by-zero?

Any help would be greatly appreciated

Share on other sites
If I have a polygon and have calculated the normal to the plane formed by the vertices of the polygon, when I perspective project those vertices from 3D to 2D is there any way to project the normal as well. What I would like to do is be able to find points along a line normal to the plane formed by the vertices of the polygon AFTER perspective projection.

thanks for the help

Share on other sites
Okay, the normal you would project could have a vector of (1,0,0), this is fine.
It has a start point and an end point, the end point being
start + (length * normal)
If this should result in you getting a point with a z of zero or less then it should be clipped in the same way you clip your poly vertex's.
In fact the view fustrum I used when I wrote my first 3D program clipped everything at about 50cm in front of the camera.

However, from what you've said, you appear to want to find the normals perspective projected values without projecting them.
I can't see how that's possible.

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
A4L
13
5. 5

• 13
• 26
• 10
• 11
• 44
• Forum Statistics

• Total Topics
633744
• Total Posts
3013657
×