-1

I currently have two points and a line between them. I have created a function called Rotate() that rotates the point along the x-axis, y-axis and z-axis. The problem I have is that I am using rotational matrices and if the points are not at the global coordinate center, the rotations mess up. So I have found a solution here, but cannot get it to work.

How can I translate these two points, so that one sits directly on [0 0 0]? ( I am trying to keep the distance and angles between them the same)

origin = [2 4 2]; % This is the point I want to put on [0 0 0] 
point = [3 2 4];

I tried using "local2globalcoord" but I could not manage...

George Lua
  • 17
  • 1
  • 5
  • 3
    `point = point - origin` would be my guess. See if that gives you `point = [1 -2 2]` – user3386109 Nov 21 '20 at 22:12
  • We can not answer as the solution depends on the notations you use like matrices are direct/inverse? multiplication order is `matrix*point` or `point*matrix`? what is the transform count and order etc and where exactly you want to translate (I do not mean coordinate but in respect to order of transforms) ... If you want universal approach then switch to [uniform transform matrices](https://stackoverflow.com/a/28084380/2521214) which are just a small expanstion of rotational matrix you got now but allows stacking up transforms and more robutst translations. – Spektre Nov 22 '20 at 09:13

1 Answers1

0

As suggested by @user3386109

point = point - origin
George Lua
  • 17
  • 1
  • 5