Gamestudio Links
Zorro Links
Newest Posts
Blog Post: Get Historical Data from Darwinex REST API w/ Zorro
by AndrewAMD
Yesterday at 22:19
Reseting a static variable - the next day
by OptimusPrime
Yesterday at 19:48
Correlation -1.#IND00
by AndrewAMD
Yesterday at 17:44
Basic thread safety question
by Superku
Yesterday at 17:43
Train algorithms separatery
by 3dgamelight
01/18/19 10:37
+BALANCED machine learning option
by jcl
01/18/19 08:37
IntraBar fluctuation
by jcl
01/18/19 08:31
AUM Magazine
Latest Screens
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Lake scene
Who's Online
4 registered (AndrewAMD, Superku, 2 invisible), 499 Guests and 6 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
laz, ramonne, SibJac, Evael, NRW
18156 Registered Users
Topic Options
Rate This Topic
#475697 - 01/04/19 04:01 Need a Math Pro (Parent / Child Rotation and XY coords)
Garrettwademan Offline
Member

Registered: 01/26/06
Posts: 242
Loc: PA
Okay guys, I am really sorry for this question, it seems so basic but I can't seem to get it. What I am trying to do is make a parent model (in this case the Computer Case) and child models (like CPU, RAM, Connectors) rotate in synconry yet keep their reletive X and Y positions to the computer case. Here is a video of what I have now, and here is the code I am using to do it. Is it because each model isn't aligned in its own axis in MED? Any help is greatly appreciated.

Its close, but not where it should be as it rotates.

YouTube Rotate Demo Current

Code:
//my is each object such as CPU, RAM, Hard Drive, Circuit Board
//arcade_Case is the Parent
//varLocDifX is the offset of the my model, relative to the arcade_Case

varLocDifX = my.x - arcade_Case.x;
varLocDifY = my.y - arcade_Case.y;
varLocDifZ = my.z - arcade_Case.z;

my.pan = arcade_Case.pan;		
my.x = arcade_Case.x + varLocDifX * cos(arcade_Case.pan + 90);
my.y = arcade_Case.y + varLocDifY * sin(arcade_Case.pan + 90);
my.z = arcade_Case.z + varLocDifZ;



Edited by Garrettwademan (01/04/19 04:05)
_________________________
Current Project: Computer Repair Simulator
https://www.computer-repair-simulator.com

Top
#475702 - 01/04/19 10:30 Re: Need a Math Pro (Parent / Child Rotation and XY coords) [Re: Garrettwademan]
txesmi Online
Serious User

Registered: 06/13/07
Posts: 1201
Loc: Hiporope and its pain
Hi,
a 2d vector rotation is computed as follows

Code:
x1 = x * cos - y * sin;
y1 = x * sin + y * cos;



Anyway, the computation of the offset vector should not be performed each frame. Otherway it will continuously lose a little length caused by the accuracy limits of the variables.

Code:
vec_diff(my.skill1, my.x, entParent.x); // save the offset vector into three skills
while(1) {
   vec_set(my.x, my.skill1);
   vec_rotate(my.x, entParent.pan);
   vec_add(my.x, entParent.x);
   vec_set(my.pan, entParent.pan);
   wait(1);
}



Salud!

Top
#475720 - 01/05/19 02:42 Re: Need a Math Pro (Parent / Child Rotation and XY coords) [Re: txesmi]
Garrettwademan Offline
Member

Registered: 01/26/06
Posts: 242
Loc: PA
Yea, that did the trick, amazing. Thank you! I am going to study more on these because I think this will help me with a bunch of other stuff too.
_________________________
Current Project: Computer Repair Simulator
https://www.computer-repair-simulator.com

Top
#475760 - 01/07/19 07:08 Re: Need a Math Pro (Parent / Child Rotation and XY coords) [Re: txesmi]
Garrettwademan Offline
Member

Registered: 01/26/06
Posts: 242
Loc: PA
I was able to use what you had and build upon it. You were very helpful. Here is a video of it all working perfectly now.

YouTube Demo Video
_________________________
Current Project: Computer Repair Simulator
https://www.computer-repair-simulator.com

Top
#475761 - 01/07/19 10:08 Re: Need a Math Pro (Parent / Child Rotation and XY coords) [Re: Garrettwademan]
txesmi Online
Serious User

Registered: 06/13/07
Posts: 1201
Loc: Hiporope and its pain
Congratulations! laugh

Top


Moderator:  HeelX, TSG_Torsten 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de