4 Replies Latest reply: Nov 9, 2012 8:44 AM by angelo_z

# Oriented Shape

Dear all!
I have a shape as
MDSYS.SDO_GEOMETRY(3003,32632,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),
MDSYS.SDO_ORDINATE_ARRAY(578769.057,4998104.786,49.0789985656738,578763.109,4998096.456,47.0639991760254,578782.6,4998099.784,47.0639991760254,578774.189,4998105.662,49.0789985656738,578769.057,4998104.786,49.0789985656738))

I need to Know orientation refer to solar.

How the angle in radians (counterclockwise from North) can be calculated?
I Have no idea!
If anyone could help please replay.

Angelo.
• ###### 1. Re: Oriented Shape
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
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
Angelo
• ###### 3. Re: Oriented Shape
Hi Angelo,

OpenGL.org gives pretty good Pseudo-Code for calculating the Normal vector of a polygon:
``````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``````
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.

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
Hi Stefan! Thanks for all, it's working.