Moving along an angle

M

Max

Is there a way to move a shape using a certain angle? For example,
starting at the center of the applet and moving forwarward, but not
just up/down/left/right or up-left/down-right/whatever, but up-up-up-
left, with a certain numerical angle?

Sorry if this is unclear, just say what you need to know.
 
A

Alex Hunsley

Max said:
Is there a way to move a shape using a certain angle? For example,
starting at the center of the applet and moving forwarward, but not
just up/down/left/right or up-left/down-right/whatever, but up-up-up-
left, with a certain numerical angle?

Yes. Why would you imagine that objects couldn't move in whatever
arbitrary you want them to?
Sorry if this is unclear, just say what you need to know.

You shouldn't come here expecting people to tease your actual question
out of you. People help here for nothing; the least they can ask is that
those wanting help actually ask a clear question....
 
O

Oliver Wong

Max said:
What is it?

You mean what is the way to move a shape using a certain angle? Google
for "trigonometry". You need to study math concepts, not Java concepts, to
understand how to do this.

- Oliver
 
B

bugbear

Max said:
Is there a way to move a shape using a certain angle? For example,
starting at the center of the applet and moving forwarward, but not
just up/down/left/right or up-left/down-right/whatever, but up-up-up-
left, with a certain numerical angle?

Sorry if this is unclear, just say what you need to know.

How is your shape defined?
What API are you using?
What do you want to do with the moved shape?

BugBear
 
J

Jeff Higgins

Max said:
Is there a way to move a shape using a certain angle? For example,
starting at the center of the applet and moving forwarward, but not
just up/down/left/right or up-left/down-right/whatever, but up-up-up-
left, with a certain numerical angle?

Sorry if this is unclear, just say what you need to know.

public class Test {

public static void main(String[] args) {

int numberOfFrames = Integer.parseInt(args[0]);
double decimalDegrees = Double.parseDouble(args[1]);
double radians = decimalDegrees * ((Math.PI / 180));
double slope = Math.tan(radians);
int xstart = 0;
int ystart = 0;
int xdelta = xstart;
int ydelta = ystart;

for(int i = 0; i < numberOfFrames; i++){
xdelta = i;
ydelta = (int)Math.rint(i * slope);
System.out.println("shape location: x = " + xdelta + " y = " +
ydelta);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top