This content has been marked as final.
Show 4 replies

1. Re: Oriented Shape
Stefan Jager Nov 8, 2012 3:16 PM (in response to angelo_z)Hi Angelo,
How do you define the orientation of an irregular shape (longest segment, average longest median if it's always more or less rectangular, centerline if it's a road surface, ....)?
In two dimensions or in three dimensions (you say something about "solar", you may need the normal vector of the shape)?
What is the requirement if you encounter a shape that is circular?
Before any of us can give you any hints, we'd need to know a bit more specific what it is you are trying to achieve and what the requirements are, which is probably a bit too much for this forum.
Cheers,
Stefan 
2. Re: Oriented Shape
angelo_z Nov 8, 2012 4:27 PM (in response to Stefan Jager)Hi Stefan! excuse my bad English,
I need to find which part of saddle roof (pitch) are looking (facing) north, so the shape is regular almost always as rectangular
But the problem is a bit too much for me not for this forum, I don’t know the geometry well enough, now I'm searching more information about: normal vector of the shape
Thanks in advance for your next help.
Angelo 
3. Re: Oriented Shape
Stefan Jager Nov 9, 2012 8:49 AM (in response to angelo_z)Hi Angelo,
OpenGL.org gives pretty good PseudoCode for calculating the Normal vector of a polygon:
Onxe you have the normal, you can use the Normal's X and Y to determine in which direction it is pointing. It shouldn't be too difficult to create a PLSQL function that accepts an SDO_GEOMETRY, calculates the normal, and then gives you back the direction for the normal.Begin Function CalculateSurfaceNormal (Input Polygon) Returns Vector Set Vertex Normal to (0, 0, 0) Begin Cycle for Index in [0, Polygon.vertexNumber) Set Vertex Current to Polygon.verts[Index] Set Vertex Next to Polygon.verts[(Index plus 1) mod Polygon.vertexNumber] Set Normal.x to Sum of Normal.x and (multiply (Current.y minus Next.y) by (Current.z plus Next.z)) Set Normal.y to Sum of Normal.y and (multiply (Current.z minus Next.z) by (Current.x plus Next.x)) Set Normal.z to Sum of Normal.z and (multiply (Current.x minus Next.x) by (Current.y plus Next.y)) End Cycle Returning Normalize(Normal) End Function
HTH,
Stefan
PS. I've never really worked with this, only played around with it so you do want to verify the formula for correctnes on a few test records. 
4. Re: Oriented Shape
angelo_z Nov 9, 2012 2:44 PM (in response to Stefan Jager)Hi Stefan! Thanks for all, it's working.