public void setTheta ( double theta ) { // Next lines are to prevent numbers like -1.8369701E-16 // when working with negative numbers if ( ( theta < - 360 ) || ( theta > 360 ) ) { theta = theta % 360 ; } if ( theta < 0 ) { theta = 360 + theta ; } double oldTheta = getTheta ( ) ; if ( ( theta < - 360 ) || ( theta > 360 ) ) { oldTheta = oldTheta % 360 ; } if ( theta < 0 ) { oldTheta = 360 + oldTheta ; } float len = length ( ) ; x = len * ( float ) FastTrig . cos ( StrictMath . toRadians ( theta ) ) ; y = len * ( float ) FastTrig . sin ( StrictMath . toRadians ( theta ) ) ; // x = x / (float) FastTrig.cos(StrictMath.toRadians(oldTheta)) // * (float) FastTrig.cos(StrictMath.toRadians(theta)); // y = x / (float) FastTrig.sin(StrictMath.toRadians(oldTheta)) // * (float) FastTrig.sin(StrictMath.toRadians(theta)); }
Calculate the components of the vectors based on a angle