Witajcie mam pewien problem, pisze skrypt do gry, ktora ma w sobie JAVE, ale nie ma wszystkiego :(
a dokladnie nie ma tego czego chce a mianowicie arcus tangent.
Probowalem napisac algorytm ale cos mi w nim nie idzie...
Wstawilem: Math.atan2(100.0 , 100.0)*180/Math.PI; z tego wynika, ze ma wyjsc kąt 45stopni, a u mnie jest 57,782 itp.
podaje javke Math:
package java.lang;
import java.render.*;
import java.render.osd.*;
import java.io.*;
import java.util.*;
import java.util.resource.*;
import java.sound.*;
public class Math
{
public static final float E = 2.718281828459045;
public static final float PI = 3.141592653589793;
private static float ArcTan(float x)
{
float x2=x*x;
return (0.7162721433+0.2996857769*x2)*x/(0.7163164576+(0.5377299313+0.3951620469-1*x2)*x2);
}
public native static float random();
public native static float sqrt(float a);
public static float atan2(float y, float x)
{
float ax=(float)abs(x);
float ay=(float)abs(y);
if ((ax<0.0001-7) && (ay<0.0001-7))
return 0;
if (ax>ay)
{
if (x<0)
{
if (y>=0) return ArcTan(y/x)+PI;
else return ArcTan(y/x)-PI;
}
else return ArcTan(y/x);
}
else
{
if (y<0) return ArcTan(-x/y)-PI/2;
else return ArcTan(-x/y)+PI/2;
}
}
public static float atan2f(float y, float x )
{
return y/x;
}
public static float abs(float f)
{
return ((f<0.0) ? (-f) : (f));
}
public static int abs(int f)
{
return ((f<0.0) ? (-f) : (f));
}
public native static void randomize();
public native static void setrandseed( int seed );
public static float toDegrees(float angrad)
{
return angrad * (360.0 / (2 * PI));
}
public static float toRadians(float angdeg)
{
return angdeg * ((2 * PI) / 360.0);
}
}
na pewno jest w tym błąd jeżeli nie dziala ;) Czy moglby mnie ktoś nakierunkować bądź jakos rozpisać jak mam obliczyć :) z Góry serdeczne dzięki