Gamestudio Links
Zorro Links
Newest Posts
error
by OptimusPrime
Yesterday at 22:10
Error message : Closing Order Quantity
by OptimusPrime
Yesterday at 22:07
Votes for future features
by ags
Yesterday at 19:19
New Zorro version 2.03
by brax
Yesterday at 11:20
Doubts about Detrend modes
by jcl
Yesterday at 08:40
Download all constituent stocks within Russel 1000
by jcl
Yesterday at 08:26
datafeed and broker are different, possible?
by jcl
Yesterday at 08:24
AUM Magazine
Latest Screens
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Who's Online
3 registered (AndrewAMD, jrath, OptimusPrime), 616 Guests and 8 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
danatrader, ilikezorro, jibanes, nandv, cam1234
18187 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 Offline
Serious User

Registered: 06/13/07
Posts: 1213
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 Offline
Serious User

Registered: 06/13/07
Posts: 1213
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