X-drive code Problem

Hello Vex forum dudes and dudettes I am an alumni for vex team 2451A and as an alumni I have been acting as a mentor for the new kids on the middle school team one of the adult mentors has assigned to me the task of coding a holonomic X-drive for the team. The reason he is teaching me to code and not the members of the team is becuase he wants me to learn to code but then also so I can teach the members of the team myself, but I have run into a few problems because this is the first time I have ever programmed a robot in my life. The .jpg is what I have so far it is showing the formula for how much power the motors get when in between straight and at a 45 degree angle (y-.5)/.003937] which is the y value on the controller telling the motor what speed between 127 and zero to go to and i have slight variations to the same expression for when the y value is between 1 and .5, .5 and 0, 0 and -.5, -.5 and -1, and the same for positive or negative x values but my question is when I have x is greater than or equal to zero I run the code where x is greater than or equal to zero but when I have it run when x is less than zero I have to same code for both side so my question is how do i differentiate between sides?

You many find this thread helpful: https://vexforum.com/t/holonomic-drives-2-0-a-video-tutorial-by-cody/27052/1

Also, it seems like the image you referred to hasn’t been attached.

I am very confused as to what you are trying to do here. Also, I don’t see anything attached. Are you using robotC or easyC?

Edit: Mystical Pie beat me by a couple seconds.

X-Drive .jpg

You’ve over complicated this by a lot, unless I’m misunderstanding what you’re trying to do.

What you’re trying to do wouldn’t work either because the motors follow a logarithmic curve; if you send a motor power of 63, about half of the max motor power, the motor will be spinning faster than half speed. You could use a truespeed array to make this happen but that’s a bit of a hassle and not really needed here.

If this is your x-drive and everything is at a 45 degree angle, let’s go through each direction:

/…
…/

FL is front left wheel
FR is front right wheel
BL is back left wheel
BR is back right wheel

Forwards & Backwards:
All wheels move in the same direction

Sideways:
FL moves in the same direction as BR but opposite of FR and BL

Diagonal:
Only two wheels move. FL and BR together or FR and BL.

So to program this to joysticks, we like to use channel mixing. Here’s some sample code:

//channel 1 is forward/back
//channel 2 is turning
//channel 3 is strafing
motor[frontLeft] = vexRT[Ch1] + vexRT[Ch2] + vexRT[Ch3];
motor[frontRight] = vexRT[Ch1] - vexRT[Ch2] - vexRT[Ch3];
motor[backLeft] = vexRT[Ch1] + vexRT[Ch2] - vexRT[Ch3]
motor[backRight] = vexRT[Ch1] - vexRT[Ch2] + vexRT[Ch3];

Thanks to all you lovely people I figured out the problem I was having and then this morning when the team met my mentor told me he purposefully made the work I was doing more difficult than it should have been so I would understand how it works better and then he helped me along programming the teams robot and I’m happy to say it works great so thank you everyone who posted to help me out.