okay, I have been trying for the past couple of weeks to get a 3 dimensional trigonometry function working, basically it accepts and origin (x, y, z) a radius, tilt, facingangle, and an angle, and returns the new 3d point.
I hope someone can help, I have been struggling with this for a very long time.
Imagine a sphere the center of which is xyz if i wanted to get the points of a circle on the xy plane of that sphere i would do
and as angle grew i would get the points along the circumference of a circle whose radius is radius and whose origin is xy.
now all i want to be able to do is make the circle able to be tilted, bringing it into the 3rd dimension <currently getting a picture for this>
so tilt will make this circle tilt towards straight upwards as the tiltangle approaches 90.0.
facingangle governs which way the circle is tilted. So if you are south and you have objects all along the circumference of a 2d circle if facingangle was 0.0 and tilt became 10.0 you would see the objects pointing up right, but if facing angle was 180.0 you would see them face up left.
Explain better what you want to do with this function, and try to make a schema..I don't understand what most of the params will do.
I realy don't know why thease minuses before angles needs, but without them this won't work perfect.
P.S. sorry for my english if I did mistakes on writing.
that was 2d trig, but here is the code of me, trying to fix it.
pawn Code:
/*Trig3D(Float:x, Float:y, Float:z, Float:radius, Float:tilt, Float:facingangle, Float:angle, &Float:retx, &Float:rety, &Float:retz)
{
new Float:xrad, Float:yrad;
xrad = ((radius * (floatcos(tilt, degrees) * floatcos(facingangle, degrees))));
yrad = ((radius * (floatcos(tilt, degrees) * floatsin(facingangle, degrees))));
retz = ((radius * floatsin(tilt, degrees) * floatsin(angle, degrees)) + z);
retx = ((xrad * floatcos(angle, degrees)) + x);
rety = ((yrad * floatsin(angle, degrees)) + y);
if (0.1 >= floatsin(tilt, degrees) >= -0.1)
{
retx = radius * floatcos(angle, degrees) + x;
rety = radius * floatsin(angle, degrees) + y;
}
return 1;
}*/
/*
Trig3D(Float:x, Float:y, Float:z, Float:radius, Float:tilt, Float:facingangle, Float:angle, &Float:retx, &Float:rety, &Float:retz)
{
retx = ((floatcos(tilt, degrees) * floatcos(angle, degrees) * radius) + x);
rety = ((floatcos(tilt, degrees) * floatsin(angle, degrees) * radius) + y);
retz = ((floatsin(tilt, degrees) * radius) + z);
return 1;
}*/
/* //backup
Trig3D(Float:x = 0.0, Float:y = 0.0, Float:z = 0.0, Float:radius = 0.0, Float:tilt = 0.0, Float:facingangle = 0.0, Float:angle = 0.0, &Float:retx = 0.0, &Float:rety = 0.0, &Float:retz = 0.0)
{
new Float:xtilt, Float:ytilt;
xtilt = floatsin(facingangle, degrees)+floatcos(tilt, degrees);
ytilt = floatcos(facingangle, degrees)+floatcos(tilt, degrees);
retx = radius * (floatcos(angle, degrees)*xtilt);
retz = radius * (floatsin((tilt), degrees)*floatsin(angle,degrees));
rety = radius * (floatsin(angle, degrees)*ytilt);
return 1;
}
*/
/* // almost there
Trig3D(Float:x = 0.0, Float:y = 0.0, Float:z = 0.0, Float:radius = 0.0, Float:tilt = 0.0, Float:facingangle = 0.0, Float:angle = 0.0, &Float:retx = 0.0, &Float:rety = 0.0, &Float:retz = 0.0)
{
new Float:xtilt, Float:ytilt;
xtilt = floatsin(facingangle, degrees)+floatcos(tilt, degrees);
ytilt = floatsin(facingangle, degrees)+floatcos(tilt, degrees);
retx = radius * (floatcos(angle, degrees)*xtilt);
retz = radius * (floatsin((tilt), degrees)*floatcos(angle,degrees));
rety = radius * (floatsin(angle, degrees)*ytilt);
return 1;
}
*/
Trig3D(Float:x = 0.0, Float:y = 0.0, Float:z = 0.0, Float:radius = 0.0, Float:tilt = 0.0, Float:facingangle = 0.0, Float:angle = 0.0, &Float:retx = 0.0, &Float:rety = 0.0, &Float:retz = 0.0)
{
new Float:xtilt, Float:ytilt;
xtilt = floatsin(tilt*floatsin(facingangle, degrees), degrees);
ytilt = floatsin(tilt*floatcos(facingangle, degrees), degrees);
retx = radius * (floatcos(angle*floatsin(facingangle, degrees)*floatcos(tilt, degrees)*floatsin(angle, degrees), degrees));
retz = radius * (floatsin((tilt), degrees)*floatcos(angle,degrees));
rety = radius * (floatsin(angle*floatcos(facingangle*floatsin(tilt, degrees)*floatsin(angle, degrees), degrees), degrees));
return 1;
retx = radius * (floatcos(0.0*0.0*1.0*0.0, degrees)); //should be 1.0 is 1.0
retx = radius * (floatcos(0.0*0.0*0.0*0.0, degrees)); //should be 0.0 is 1.0
retx = radius * (floatcos(90.0*0.0*1.0*1.0, degrees)); //should be 1.0 is 1.0
retx = radius * (floatcos(0.0*1.0*0.0*1.0, degrees)); //should be 1.0 is 1.0
retx = radius * (floatcos(0.0*1.0*1.0*1.0, degrees)); //should be 0.0 is 1.0
retx = radius * (floatcos(90.0*0.0*1.0*0.0, degrees)); //should be 1.0 is 1.0
retx = radius * (floatcos(0.0*floatsin(0.0, degrees)*floatcos(0.0, degrees)*floatsin(0.0, degrees), degrees)); //should be 1.0
retx = radius * (floatcos(0.0*floatsin(0.0, degrees)*floatcos(90.0, degrees)*floatsin(0.0, degrees), degrees)); //should be 0.0
retx = radius * (floatcos(90.0*floatsin(90.0, degrees)*floatcos(90.0, degrees)*floatsin(90.0, degrees), degrees)); //should be 1.0
retx = radius * (floatcos(0.0*floatsin(0.0, degrees)*floatcos(0.0, degrees)*floatsin(0.0, degrees), degrees)); //should be 1.0
retx = radius * (floatcos(0.0*floatsin(0.0, degrees)*floatcos(90.0, degrees)*floatsin(0.0, degrees), degrees)); //should be 0.0
retx = radius * (floatcos(90.0*floatsin(90.0, degrees)*floatcos(90.0, degrees)*floatsin(90.0, degrees), degrees)); //should be 1.0
}
/* //some problems
Trig3D(Float:x = 0.0, Float:y = 0.0, Float:z = 0.0, Float:radius = 1.0, Float:tilt = 0.0, Float:facingangle = 0.0, Float:angle = 0.0, &Float:retx = 0.0, &Float:rety = 0.0, &Float:retz = 0.0)
{
new Float:xtilt, Float:ytilt;
xtilt = floatsin(facingangle*floatsin(tilt, degrees), degrees);
ytilt = floatcos(facingangle*floatsin(tilt, degrees), degrees);
printf("%f %f", xtilt, ytilt);
retx = radius * (floatsin(angle*(floatsin(xtilt*90.0, degrees)), degrees));
retz = radius * (floatsin((tilt)*floatcos(angle, degrees), degrees));
rety = radius * (floatsin(angle, degrees)*ytilt);
return 1;
}
*/
/*
Trig3D(Float:x = 0.0, Float:y = 0.0, Float:z = 0.0, Float:radius = 0.0, Float:tilt = 0.0, Float:facingangle = 0.0, Float:angle = 0.0, &Float:retx = 0.0, &Float:rety = 0.0, &Float:retz = 0.0)
{
new Float:xtilt, Float:ytilt, Float:xangle, Float:yangle;
xtilt = floatsin(facingangle, degrees)+floatcos(tilt, degrees);
ytilt = floatsin(facingangle, degrees)+floatcos(tilt, degrees);
xangle = floatsin(facingangle, degrees)*floatcos(tilt, degrees)
yangle = floatsin(facingangle, degrees)*floatcos(tilt, degrees);
retx = radius * (floatcos(angle*xangle, degrees)*xtilt);
retz = radius * (floatsin((tilt), degrees)*floatcos(angle+tilt-90.0,degrees));
rety = radius * (floatsin(angle*yangle, degrees)*ytilt);
return 1;
}
*/
/*Trig3D(Float:x, Float:y, Float:z, Float:radius, Float:tilt, Float:facingangle, Float:angle, &Float:retx, &Float:rety, &Float:retz)
{
if (0.1 >= floatsin(tilt, degrees) >= -0.1)
{
retz = z;
retx = radius * floatcos(angle, degrees) + x;
rety = radius * floatsin(angle, degrees) + y;
}
else
{
new Float:temprad;
temprad = (((radius) * floatsin(tilt, degrees)) );
retz = ((temprad * floatcos(tilt, degrees)) + z);
retx = ((temprad * floatcos(angle, degrees)) + x);
rety = ((temprad * floatsin(angle, degrees)) + y);
}
return 1;
}*/
/*Trig3D(Float:x, Float:y, Float:z, Float:radius, Float:tilt, Float:facingangle, Float:angle, &Float:retx, &Float:rety, &Float:retz)
{
if (0.1 >= floatsin(tilt, degrees) >= -0.1)
{
retz = z;
retx = radius * floatcos(angle, degrees) + x;
rety = radius * floatsin(angle, degrees) + y;
}
else
{
retx = x + (radius * floatcos(angle, degrees) * floatsin(tilt, degrees));
rety = y + (radius * floatsin(angle, degrees) * floatsin(tilt, degrees));
retz = z + (radius * floatcos(tilt, degrees));
}
return 1;
}*/
/*
Trig3D(Float:x, Float:y, Float:z, Float:radius, Float:tilt, Float:facingangle, Float:angle, &Float:retx, &Float:rety, &Float:retz)
{
new Float:anglex = (floatcos(tilt, degrees) * floattan(facingangle, degrees)) * floatcos(angle, degrees);
new Float:angley = floatcos(tilt, degrees) * floattan(facingangle, degrees) * floatsin(angle, degrees);
new Float:anglez = floatsin(tilt, degrees) * floatsin(angle, degrees);
printf("%f %f %f", anglex, angley, anglez);
retx = x;
rety = floatcos(anglex, degrees)*y - floatsin(anglex, degrees)*z;
retz = floatsin(anglex, degrees)*y + floatcos(anglex, degrees)*z;
retx = floatcos(angley, degrees)*retx - floatsin(angley, degrees)*rety;
rety = floatsin(angley, degrees)*retx + floatcos(angley, degrees)*rety;
retz = retz;
retx = floatcos(anglez, degrees)*retx - floatsin(anglez, degrees)*retz;
rety = rety;
retz = floatsin(anglez, degrees)*retx + floatcos(anglez, degrees)*retz;
retx *= radius;
rety *= radius;
retz *= radius;
return 1;
}
*/