4 Replies Latest reply on Nov 9, 2012 2:44 PM by angelo_z

    Oriented Shape

      Dear all!
      I have a shape as

      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.

      Thanks for your help
        • 1. Re: Oriented Shape
          Stefan Jager
          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.

          • 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
            Thanks in advance for your next help.
            • 3. Re: Oriented Shape
              Stefan Jager
              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.


              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.