# Implementation of Inverse Kinematics in Java

```import java.io.*;

class IK
{
publicstaticvoid main(String args[]) throwsIOException{

double w[] = newdouble [6];
double a[] = newdouble[4];
double d[] = newdouble[4];
double q[] = newdouble[4];

System.out.println("Enter values for W");
for(inti =0;i<6;i++)
{
System.out.print("w"+(i+1) + ":");
System.out.println();
}

System.out.println("Enter values for joint distance");
for(inti = 0;i<4;i++)
{
System.out.print("d"+(i+1)+ ":");
System.out.println();
}

for(inti = 0;i<4;i++)
{
System.out.print("a"+(i+1)+ ":");
System.out.println();
}

q[2] = d[0]-w[2]-d[3];
double t11 = Math.pow(w[0],2)+Math.pow(w[1],2)-Math.pow(a[0], 2)-Math.pow(a[1], 2);
double t12 = 2*a[0]*a[1];
q[1] = Math.toDegrees(Math.acos(t11/t12));

q[0] = Math.toDegrees(Math.atan((t21+t22)/(t31-t32)));
q[3] = Math.PI*Math.log(Math.abs(w[5]));

System.out.println("The I.K/ of SCARA is " +q[0]+" " +q[1]+" "+q[2]+" "+q[3]);

}
}

/*OUTPUT:
Enter values for W
w1:203.4

w2:662.7

w3:557

w4:0

w5:0

w6:-1.649

Enter values for joint distance
d1:877

d2:0

d3:0

d4:200