I am trying to rotate the sphere with a point that rotates 360 degrees (which was a success) but when the angle value is 0, then the sphere moves to the centre. For which the code was:-
float ang = radians(chf("ang"));
float rad = chf("rad");
for( int i = 0; i<ang; i++){
float x = cos(ang) * rad;
float z = sin(ang) * rad;
@P = set(x, 0, z);
}
So to fix this problem and to have the point on one the coordinate of radius, I used the second code using if statement( and it was also a success but it felt like it was a bit longer):-
float ang = radians(chf("ang"));
float rad = chf("rad");
for( int i = 0; i<ang; i++){
float x = cos(ang) * rad;
float z = sin(ang) * rad;
@P= set(x, 0, z);
f@newx = x;
f@newz = z;
}if (ang ==0){
float x = f@newx;
float z = f@newz;
z = rad;
@P = set(x, 0, z);
}
So, I am trying to find a solution to how to make it a bit shorter. Here's my attempt at that ( and it is showing an error):-
float ang = radians(chf("ang"));
float rad = chf("rad");
if ( ang != 0){
for( int i = 0; i<ang; i++){
float x = cos(ang) * rad;
float z = sin(ang) * rad;
@P = set(x, 0, z);
}
}else{
x = radians(rad);
z = radians(rad);
@P = set(x, 0, z);
}
}
Is there a way to improve that/a better way to fix the position when the angle is 0?