Boat heading and movement.
Posted: Tue Mar 15, 2011 12:42 pm
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number:
L2JDP Revision Number:
I made the following function that is supposed to "move" a boat with a given distance and a given change in its angle from a given anchor point ( x, y ). It basically calculates the new point based on the polar coordinate and returns the cartesian coordinates. With zero angle , isnt it supposed to go forward instead of turning ? Im testing it and it seems the ship is always turning randomply.
» Find Revision
L2J Revision Number:
L2JDP Revision Number:
I made the following function that is supposed to "move" a boat with a given distance and a given change in its angle from a given anchor point ( x, y ). It basically calculates the new point based on the polar coordinate and returns the cartesian coordinates. With zero angle , isnt it supposed to go forward instead of turning ? Im testing it and it seems the ship is always turning randomply.
Code: Select all
public int[] calculatePoint2(int x, int y, int rotate, int distance) { int angle = (int) (boat.getHeading()/182.044444 + rotate); if(angle > 360) angle = angle -360; if(angle < 0) angle = 360 - angle; int dx = (int) (Math.cos(angle)* distance); int dy = (int) (Math.sin(angle)* distance); int[] result = new int[2]; result[0] = x + dx; result[1] = y + dy; return result; }