AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [SOLVED]Rotate point around vector? (https://forums.alliedmods.net/showthread.php?t=250435)

Alka 10-24-2014 18:45

[SOLVED]Rotate point around vector?
 
1 Attachment(s)
I have 2 points origins(P1 and P2) and a third point(P3) that is at distance N from P2. Now what i want to make is to rotate P3 around P2 at N distance by M angles. Made a lot of researches and searches but didn't understand so much because of my lack of maths ;s if anyone around knows an answer then thank you. :bacon:

Some useful info? http://ami.ektf.hu/uploads/papers/fi...om175to186.pdf

Dr. Greg House 10-24-2014 19:44

Re: Rotate point around vector?
 
Are we sticking to the example which is 2d, or do you need a 3d solution?

EDIT:
Oh dear, I didn't see the z-axis in the graph, yet wondered why the circle was so skewed.

You're going to have to define a rotation matrix, subtract p2 from p3, rotate it by multiplying it with the matrix, then readd p2.
And yes, the pdf is what you need.
Any specific issues we might help you with?

Alka 10-25-2014 01:53

Re: Rotate point around vector?
 
EDIT: Solution found, there was a mistake, where rotation[0][3] / [1][3] / [2][3] was initially 0 because vector supposed to start from (0,0,0). Replaced those with last column from rotation matrix
http://inside.mines.edu/fs_home/gmur...otation14x.png
where a,b,c = P1 and now works as intended. Also angle conversion wasn't needed.
I'll leave code here in case someone will eventually need this somewhere? Thank you for your suggestion Greg :wink:

Spoiler


All times are GMT -4. The time now is 00:33.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.