Reputation: 413
I am looking for an answer to find an angle-alpha for cosine.
cos(alpha)=RT(vector).R(vector)/(modulus)RT(vector).(modulus)R(vector)
then I should need to find the angle alpha.
public double dot1(double[] vectorA, double[] vectorB){
double[] vecPro;
vecPro = new double[2];
vecPro[0] = vectorA[0]*vectorB[0];
vecPro[1] = vectorA[1]*vectorB[1];
return 0;
}
this code is just an sample I did so far! for the dot product of RT(vector).R(vector)
.
hmm is that correct that I did, because I am new to java language.
Upvotes: 0
Views: 208
Reputation: 719576
It is hard to figure out what you are really asking, but the place to find implementations of the trigonometric functions like sine, cosine and tangent is the java.lang.Math
class.
Upvotes: 1
Reputation: 9260
That doesn't calculate dot product. This does
public double dot1(double[] vectorA, double[] vectorB){ //if they're from R^2
double[] vecPro = new double[2];
vecPro[0] = vectorA[0]*vectorB[0];
vecPro[1] = vectorA[1]*vectorB[1];
//you did fine up to here
//But, you should return the result (sum of components products) @see wiki link
//0 surely isn't the result you want for two arbitrary vectors
return vecPro[0] + vecPro[1];
}
Upvotes: 2