Clean up main sketch
Imported from 'hexapod 2.rar'.
This commit is contained in:
1 parent
78c5c11d41
commit
c977b3acab
1 file changed
+32
-80
@@ -42,7 +42,7 @@ void draw()
|
|||||||
|
|
||||||
translate(width/2, height/2, 0);
|
translate(width/2, height/2, 0);
|
||||||
|
|
||||||
switch(/*i5*/2)
|
switch(i5)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
rotateX(-1*(PI/10));
|
rotateX(-1*(PI/10));
|
||||||
@@ -61,9 +61,9 @@ void draw()
|
|||||||
|
|
||||||
float rotationRange = 8;
|
float rotationRange = 8;
|
||||||
|
|
||||||
//rotationX = ( i3%(rotationRange*4) < (rotationRange*2) ? -rotationRange+i3%(rotationRange*2) : rotationRange+(-1*(i3%(rotationRange*2))) );
|
rotationX = ( i3%(rotationRange*4) < (rotationRange*2) ? -rotationRange+i3%(rotationRange*2) : rotationRange+(-1*(i3%(rotationRange*2))) );
|
||||||
rotationY = ( i4%(rotationRange*4) < (rotationRange*2) ? -rotationRange+i4%(rotationRange*2) : rotationRange+(-1*(i4%(rotationRange*2))) );
|
rotationY = ( i4%(rotationRange*4) < (rotationRange*2) ? -rotationRange+i4%(rotationRange*2) : rotationRange+(-1*(i4%(rotationRange*2))) );
|
||||||
//rotationZ = ( i2%(rotationRange*4) < (rotationRange*2) ? -rotationRange+i2%(rotationRange*2) : rotationRange+(-1*(i2%(rotationRange*2))) );
|
rotationZ = ( i2%(rotationRange*4) < (rotationRange*2) ? -rotationRange+i2%(rotationRange*2) : rotationRange+(-1*(i2%(rotationRange*2))) );
|
||||||
|
|
||||||
if (c2.delay(25))
|
if (c2.delay(25))
|
||||||
{
|
{
|
||||||
@@ -145,9 +145,7 @@ void draw()
|
|||||||
{
|
{
|
||||||
animationSubStep++;
|
animationSubStep++;
|
||||||
}
|
}
|
||||||
|
|
||||||
animationSubStep = 0; // REMOVE
|
|
||||||
|
|
||||||
foot1.SetFootCoordinates(Animation(2));
|
foot1.SetFootCoordinates(Animation(2));
|
||||||
foot2.SetFootCoordinates(Animation(3));
|
foot2.SetFootCoordinates(Animation(3));
|
||||||
foot3.SetFootCoordinates(Animation(4));//
|
foot3.SetFootCoordinates(Animation(4));//
|
||||||
@@ -348,86 +346,20 @@ class Foot
|
|||||||
|
|
||||||
void RotateX()
|
void RotateX()
|
||||||
{
|
{
|
||||||
if (leftLegorRight)
|
Y = Y * cos(radians(rotationX)) - Z * sin(radians(rotationX));
|
||||||
{
|
Z = Y * sin(radians(rotationX)) + Z * cos(radians(rotationX));
|
||||||
double yt = Y + TranslateY;
|
|
||||||
double zt = Z + TranslateZ;
|
|
||||||
|
|
||||||
double NY = yt * cos(radians(rotationX)) - zt * sin(radians(rotationX));
|
|
||||||
double NZ = yt * sin(radians(rotationX)) + zt * cos(radians(rotationX));
|
|
||||||
|
|
||||||
Y = NY - TranslateY;
|
|
||||||
Z = NZ - TranslateZ;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
double yt = Yi + TranslateY;
|
|
||||||
double zt = Zi + TranslateZ;
|
|
||||||
|
|
||||||
double NY = yt * cos(radians(rotationX)) - zt * sin(radians(rotationX));
|
|
||||||
double NZ = yt * sin(radians(rotationX)) + zt * cos(radians(rotationX));
|
|
||||||
|
|
||||||
Y = NY - TranslateY;
|
|
||||||
Z = NZ - TranslateZ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateY()
|
void RotateY()
|
||||||
{
|
{
|
||||||
if (leftLegorRight)
|
Z = Z * cos(radians(rotationY)) - X * sin(radians(rotationY));
|
||||||
{ // Right
|
X = Z * sin(radians(rotationY)) + X * cos(radians(rotationY));
|
||||||
/*double xt = (-1*X) + TranslateX;
|
|
||||||
double zt = -1*(Z + TranslateZ);
|
|
||||||
|
|
||||||
double NZ = zt * cos(radians(rotationY)) - xt * sin(radians(rotationY));
|
|
||||||
double NX = zt * sin(radians(rotationY)) + xt * cos(radians(rotationY));
|
|
||||||
|
|
||||||
X = -1 * (NX - TranslateX);
|
|
||||||
Z = -1*(NZ + TranslateZ);*/
|
|
||||||
double xt = (-1*X) + TranslateX;
|
|
||||||
double zt = (-1*Z) + TranslateZ;
|
|
||||||
|
|
||||||
double NZ = zt * cos(radians(rotationY)) - xt * sin(radians(rotationY));
|
|
||||||
double NX = zt * sin(radians(rotationY)) + xt * cos(radians(rotationY));
|
|
||||||
|
|
||||||
X = -1 * (NX - TranslateX);
|
|
||||||
Z = -1 * (NZ - TranslateZ);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
double xt = X + TranslateX;
|
|
||||||
double zt = Z + TranslateZ;
|
|
||||||
|
|
||||||
double NZ = zt * cos(radians(rotationY)) - xt * sin(radians(rotationY));
|
|
||||||
double NX = zt * sin(radians(rotationY)) + xt * cos(radians(rotationY));
|
|
||||||
|
|
||||||
X = NX - TranslateX;
|
|
||||||
Z = NZ - TranslateZ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateZ()
|
void RotateZ()
|
||||||
{
|
{
|
||||||
if (leftLegorRight)
|
X = X * cos(radians(rotationZ)) - Y * sin(radians(rotationZ));
|
||||||
{
|
Y = X * sin(radians(rotationZ)) + Y * cos(radians(rotationZ));
|
||||||
double xt = (-1*X) + TranslateX;
|
|
||||||
double yt = Y + TranslateY;
|
|
||||||
|
|
||||||
double NX = xt * cos(radians(rotationZ)) - yt * sin(radians(rotationZ));
|
|
||||||
double NY = xt * sin(radians(rotationZ)) + yt * cos(radians(rotationZ));
|
|
||||||
|
|
||||||
X = -1 * (NX - TranslateX);
|
|
||||||
Y = NY - TranslateY;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
double xt = X + TranslateX;
|
|
||||||
double yt = Y + TranslateY;
|
|
||||||
|
|
||||||
double NX = xt * cos(radians(rotationZ)) - yt * sin(radians(rotationZ));
|
|
||||||
double NY = xt * sin(radians(rotationZ)) + yt * cos(radians(rotationZ));
|
|
||||||
|
|
||||||
X = NX - TranslateX;
|
|
||||||
Y = NY - TranslateY;
|
|
||||||
Z = Zi;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RL3 ()
|
void RL3 ()
|
||||||
@@ -503,9 +435,29 @@ class Foot
|
|||||||
Y = Yi;
|
Y = Yi;
|
||||||
Z = Zi;
|
Z = Zi;
|
||||||
|
|
||||||
|
if (leftLegorRight)
|
||||||
|
{ // Right
|
||||||
|
X = (-1*X) + TranslateX;
|
||||||
|
Z = (-1*Z) + TranslateZ;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
X = Xi + TranslateX;
|
||||||
|
Z = (-1*Z) + TranslateZ;
|
||||||
|
}
|
||||||
|
|
||||||
RotateY();
|
RotateY();
|
||||||
//RotateX();
|
RotateX();
|
||||||
//RotateZ();
|
RotateZ();
|
||||||
|
|
||||||
|
if (leftLegorRight)
|
||||||
|
{ // Right
|
||||||
|
X = -1 * (X - TranslateX);
|
||||||
|
Z = -1 * (Z - TranslateZ);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
X -= TranslateX;
|
||||||
|
Z = -1 * (Z - TranslateZ);
|
||||||
|
}
|
||||||
|
|
||||||
double a = (90 - degrees((float)(O1())));
|
double a = (90 - degrees((float)(O1())));
|
||||||
double b = (180 - degrees((float)(T1())));
|
double b = (180 - degrees((float)(T1())));
|
||||||
|
|||||||
Reference in new issue
Block a user