Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- How to convert world coordinates to local coordinates, relative to for...

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 07-22-2023 10:05 AM
(1618 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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* = T*x* + *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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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 ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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 *e _{1}* = (1, 0, 0)',

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.

Ready to level-up your skills? Choose your own adventure.