BookmarkSubscribeRSS Feed
squad4
Calcite | Level 5

Hello, I'm trying to find an optimal solution for a problem I'm having. I'm looking for 3D solution.

I'm trying to convert a Point from world coordinates to the local coordinates of a specific Object, so that when the Object rotates/changes position, I would still be able to find new coordinate for the Point, that would be have the same relation (position/rotation) to the Object as during the initial state.

I have the Forward, Right, Up vector of this Object; its position in world coordinates as well as the position of the Point in world coordinates.

I was thinking I could get the difference in angles between the vector from Object's origin to Point's origin and the Forward vector of the Object, and then rotate by this difference from the Forward vector backwards to get the direction of the desired vector, but that is unreliable. So I'm assuming I will have to use some transformation Matrix for this.

What are the maths for my exact situation, where I'd be using a custom axis (the Forward vector of my object) and to do the conversion from world to local coordinates?

4 REPLIES 4
ballardw
Super User

Do you have some sort of digital elevation model data set with elevation associated with a geographic coordinate system?

That would be the first thing to look for. Free data of that sort is not very widespread.

I would, because many years ago I had some training with this software, start at https://grass.osgeo.org/ as the pure SAS solutions in SAS/GIS require additional license.

 

GIS software for 3d spatial problems generally.

FreelanceReinh
Jade | Level 19

Hello @squad4 and welcome to the SAS Support Communities!

 


@squad4 wrote:

(...) I have the Forward, Right, Up vector of this Object; its position in world coordinates as well as the position of the Point in world coordinates. (...)

What are the maths ... to do the conversion from world to local coordinates?


So your "local coordinates" are defined by three (column) vectors f ("forward"), r ("right") and u ("up") forming an orthonormal basis of R³ and a vector c to the origin of the object's coordinate system. Then the transformation from local to "world coordinates" is easy: If x is a vector ("point") in local coordinates, use the transformation matrix T:=(f, r, u) and the translation vector c to obtain the corresponding vector x in world coordinates: x = Tx + c.

 

Now the inverse transformation, i.e. from world to local coordinates, is not difficult either: Remembering that the inverse of an orthogonal matrix (such as T) is just its transpose (T'), we obtain

x = T'(x-c)

 

When the object "rotates/changes position," matrix T and vector c change correspondingly.

Nikitha_K
Calcite | Level 5

Hello,

I was having the same sort of issue using your solution i was able to get the result, but using this formula i was only able to calculate the position of the point, how to calculate the orientation of the point ?

FreelanceReinh
Jade | Level 19

Hello @Nikitha_K and welcome to the SAS Support Communities!

 

If the determinant, det T, of the transformation matrix T is positive, the basis f, r, u of R³ has the same orientation as the canonical basis e1 = (1, 0, 0)', e2 = (0, 1, 0)', e3 = (0, 0, 1)' (defining the world coordinate system). If det T < 0, the two orientations are different. (Remember that R³ has only two orientations.)

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 863 views
  • 2 likes
  • 4 in conversation