It's possible that some of the divisions are being performed on ints, so the decimals are getting lost (it's hard to tell without knowing the types of the variables). Give this a try, to be sure I'm making explicit the casts:
tri1 = Math.atan(((double)offsetDepth) / offsetLength);
marking1 = Math.sqrt(Math.pow(offsetLength,2) + Math.pow(offsetDepth,2));
tri2 = (180 - tri1) / 2.0;
marking2 = ductDepth / Math.tan(tri2);
Also, as pointed by @CommonsWare, it's a mistake to assume that Math.PI
is equal to 180
.
EDIT
You updated the question to indicate that the variables are in fact, double
s. So the above doesn't apply, but I'd advise you to remember that in Java all trigonometric operations receive their input in radians, if you're using degrees (as it seems to be the case, because you're subtracting from 180) then you'll have to make sure that all the operations are getting their inputs in radians, convert the input that is in degrees to radians before passing it to the trigonometric functions.