code/trigonometry/Joystick : how to map x y values

Hello!
After some research, i am seeking help for a project...
I want to use a Joystick to control the speed of 5 motors.
I want to map de X Y values to a circle using trigonometry I guess, basing on a
pentagram... each portion of the pentagram would be assigned to one motor, the speed being
controled by the distance from the center...
I don't know if i am clear, and if it is even possible, as I am a total noob !
HELP!!

Thank you very much !

5 egal portions... maped from x y values https://upload.wikimedia.org/wikipedia/commons/thumb/0/01/Regular_polygon_5_annotated.svg/1200px-Regular_polygon_5_annotated.svg.png

You have a known center point (512, 512) and some value that you want to know the distance and angle to. That is really not hard. The distance is the square root of the sum of the squares of the two shorter edges of the triangle. Google "polar coordinate system" to learn all about determining the angle to the point. Then, it's a matter of some if and else if statements, to determine which of the 5 segments the joystick point in.

To calculate an angle from the center you use the following formula:

#include <math.h>

var deltaX = XAxis - 512;
var deltaY = yAxis - 512;
double rad = atan2 (deltaY, deltaX); // In radians

// For conversion to degrees you use the following formula:
double deg = rad * 57.295779513082320876798154814105; // we assume that a radian is 57.29 and a bit degrees.

// to calculate the distance from the center (and, therefore, resulting force of motors) we use classic Pythagoras equation:
var dist = sqrt(deltaX*deltaX + deltaY*deltaY); // I use this silly ^2 multiplication, as Arduino's pow() function is prone to errors

This thing should return the angle deeming that straight upward vector is 0 degrees. It is your job to determine what angle to corresponds to which sector.
Oh! And beware of horizontal (deltaX ==0) angles as those may result in division by zero!

I don't know the scale or the nuances of your joystick, but it seems that your motors shall be 40% more eager to work diagonally than vertically or horizontally.

P.S. How old are you? Just asking... As people seem to forget trigonometry with age.
P.P.S. Had to update this message. Got very confused by some code issues.

Hey !
Thank you guys for your help
it works ! so much fun

below the code I'm going with, it is
for an interface with 6 faders and 1 joystick..
motors are hitting springs attached to home made percussions.

If you have any sugestions on how to improve..
I am reading!! it is still simple, and I will implement more controls and "musical" subdivisions etc

PS:I am 24years old, a bit retarded, I have Timmy's Syndrome

code:
#include <math.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"

Adafruit_MotorShield AFMStop(0x61);
Adafruit_MotorShield AFMSbot(0x60);

Adafruit_DCMotor *myMotor1 = AFMSbot.getMotor(1);
Adafruit_DCMotor *myMotor2 = AFMSbot.getMotor(2);
Adafruit_DCMotor *myMotor3 = AFMSbot.getMotor(3);
Adafruit_DCMotor *myMotor4 = AFMSbot.getMotor(4);
Adafruit_DCMotor *myMotor5 = AFMStop.getMotor(1);

int potPin8 = A8;
int potPin9 = A9;
int potPin10 = A10;
int potPin11 = A11;
int potPin12 = A12;
int joyPinX = A13;
int joyPinY = A14;

int val8 = 0;
int val9 = 0;
int val10 = 0;
int val11= 0;
int val12 = 0;
int valX = 0;
int valY = 0;

void setup() {

AFMSbot.begin();
AFMStop.begin();
Serial.begin(9600);
}

void loop() {

joyPinX = analogRead(13) - 512;
joyPinY = analogRead(14) - 512;

int angle = (atan2(joyPinX, joyPinY));
double deg = atan2(joyPinX, joyPinY) * 57.295779513082320876798154814105;

Serial.println(deg);

if ((deg >=-10) && (deg<= 20)) {
myMotor1->setSpeed(potPin8);
myMotor1->run(FORWARD);
}
else if ((deg >=-100) && (deg<= -11)) {
myMotor2->setSpeed(potPin9);
myMotor2->run(FORWARD);
}
else if ((deg >=-180) && (deg<= -100)) {
myMotor3->setSpeed(potPin10);
myMotor3->run(FORWARD);
}
else if ((deg >=130) && (deg<= 160)) {
myMotor4->setSpeed(potPin11);
myMotor4->run(FORWARD);
}
else if ((deg >=30) && (deg<= 99)) {
myMotor5->setSpeed(potPin12);
myMotor5->run(FORWARD);
}
else {
myMotor1->setSpeed(0);
myMotor1->run(FORWARD);

myMotor2->setSpeed(0);
myMotor2->run(FORWARD);

myMotor3->setSpeed(0);
myMotor3->run(FORWARD);

myMotor4->setSpeed(0);
myMotor4->run(FORWARD);

myMotor5->setSpeed(0);
myMotor5->run(FORWARD);
}
}