Hello,

How can I calculate the normal vector giving a vertex on a 2D plane in OpenGL. ?

All what I read was all about 3D and cross product of two vectors. the only thing that I have is that vertex and I want to construct a vector coming out of it.

any help?

Thanks

The problem isn't with OpenGL - it is just an interface to display stuff on the screen. Calculating the vector is the main problem. That is simple calculus or vector algebra. Refresh your math and go from there!

the reason for drawing this vector is to be the start of my rotation,
thats why I chose openGL becuase i need to apply some graphics after that.

giving a vertex on a 2D plane

What information do you have about the plane? (equations, points, etc?)

This does a nice job of explaining things.

To get the normal out of a vertex on the edge of a 2D polygon, you take the vector that goes from the point just before to the point just after, and then you rotate that vector by 90 degrees ccw (right-hand rule). You can do that by swaping (x,y) with (-y,x). That's all! (it's actually the same as taking the cross-product, in 3D, with a vector pointing directly out of the 2D plane).

Yes, thank you for the helpful imformation.

Be a part of the DaniWeb community

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