Returns the angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI]. @param v1 the other vector @return the angle in radians in the range [0,PI]
(Vec3D v1)
| 149 | * @return the angle in radians in the range [0,PI] |
| 150 | */ |
| 151 | public final double angle(Vec3D v1) { |
| 152 | double vDot = this.dot(v1)/(this.magnitude()*v1.magnitude()); |
| 153 | if(vDot<-1.0) { |
| 154 | vDot = -1.0; |
| 155 | } |
| 156 | if(vDot>1.0) { |
| 157 | vDot = 1.0; |
| 158 | } |
| 159 | return((Math.acos(vDot))); |
| 160 | } |
| 161 | |
| 162 | } |
| 163 |