View Full Version : I need to program a test for polygonal convexity
I've just started programming in OpenGL. For my first program I need to create a polygon by clicking the mouse in the window. Each left-click adds a vertex, when I'm done clicking, I hit enter and the program displays the program. This portion I have working already. I just store the values of the vertices in a 3 dimensional array, the figure is 2d. How do I go about coding a test to determine if the polygon is convex or not?
11-11-2003, 03:25 PM
If the polygon is defined by edges E1, E2,...En;
E1 X E2, E2 X E3,... En-1 X En all should point in the same direction (either up from the polygon or down ... assuming the polygon is planer.. contained in a single plane.)
Could you elaborate please? I'm unsure as to what you mean.
11-11-2003, 05:24 PM
asuming your vertexs are (x1,y1,z1),(x2,y2,z2),(x3,y3,z3),(x...,y...,z...) and all the z coords are the same, then
n should be + or - depending if the points are convex or concave or will be 0 if in a streight line
email me if it dosnt work, I wrote this from memory email address is firstname.lastname@example.org
11-11-2003, 06:56 PM
Check that the dot products of each line pair in the sequence have the same sign, make sure you check the boundary condition.
11-12-2003, 12:39 PM
the dot product is just a multiplication of the coordinates of each point, for example u=(u1,u2,u3...un) v=v1,v2,v3...vn) thus the dot product would be
u . v = (u1v1+u2v2+u3v3...unvn)
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.