Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Translating offset vectors between two locations

Greetings kind reader,

Starting with a known location and knowing an object's position relative to that location, I need to determine the position with the same offset from another location. I plain English, I am teleporting a player between two identical rooms without him/her being able to tell it happened.

There are simplied images below that should help explain. In all cases, the known location is the yellow sphere, the green sphere is the object (player) whose position relative to the yellow sphere is known, the blue sphere is the second known location and the location of the red sphere (where the player is teleported to) is what needs to be determined. The multicolored lines between the spheres are just there for scale.

I have a feeling this is one of those things that is simple once you know what function(s) to use, but I don't and it has been ages since I used vector math in school. A combination of trial and error and monkey see monkey do with FQuat, FTransform, FRotator and FVector has led me to a solution for this simple case and ones where the two locations are at varying angles and distances from the Z (blue line) axis.

alt text

But I have not been able to convert that solution to one where the floor is tilted as below, where the tilt is known.

alt text

And what I really need is to be able to do it for floors with differing known tilts from horizontal and differing known rotations around Z, as shown below.

alt text

Ideally it would be nice to be able to do this for a start location with arbitrary known location and rotation and a destination with arbitrary known location and rotation, and I am hoping that with your help it will be possible to do this.

Thanks for taking the time to look at this,


Product Version: Not Selected
more ▼

asked Apr 02 '15 at 03:59 PM in C++ Programming

avatar image

135 17 13 23

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I'm not sure, but I think a nice try would be to make a substraction between the green and yellow point. Then, you know the relative distance between both of them. Then, you should add this resulting vector to the position of the blue sphere, and teleport there the player.

I'm not sure if I understood you correctly, but if your levels are mirrored or something like that, you just have to change the value of the mirrored axis. For the rotation issue, it's a bit more complicated (but not so much!). I would calculate the vector between the green and yelow units in local, and apply it to the blue sphere in local (so it calculates the position according the rotations!)

It's a quite simplistic and fast answer, but I hope this helped! :T

more ▼

answered Jun 04 '17 at 06:52 PM

avatar image

Mighty Marcos
106 6 9 15

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question