# Drawing Lines by Angles

Matthew Sparkes

Greenhorn

Posts: 2

posted 9 years ago

- 0

Hi everyone, this is my first post here.

I'm writing a program at the moment, where I will have an array of ints representing angles. I will then have a series of dots connected by lines of fixed length, where the dots deviate from the upright by a certain angle.

This will allow me to plot a graph, but only storing one set of numbers.

Currently I have worked out the positions manually, and these are kept in X and Y int arrays. What I want is to be able to do something like I am currently doing with polyline, but instead using angles rather than cartesian points, but all the while keeping the seperation (line length) constant.

Any ideas?

I'm writing a program at the moment, where I will have an array of ints representing angles. I will then have a series of dots connected by lines of fixed length, where the dots deviate from the upright by a certain angle.

This will allow me to plot a graph, but only storing one set of numbers.

Currently I have worked out the positions manually, and these are kept in X and Y int arrays. What I want is to be able to do something like I am currently doing with polyline, but instead using angles rather than cartesian points, but all the while keeping the seperation (line length) constant.

Any ideas?

<a href="http://non-tech-city.com/" target="_blank" rel="nofollow">Non-Tech City</a><br /><a href="http://non-tech-city.com/" target="_blank" rel="nofollow">Matthew Sparkes</a>

Keith Lynn

Ranch Hand

Posts: 2399

Matthew Sparkes

Greenhorn

Posts: 2

posted 9 years ago
<a href="http://non-tech-city.com/" target="_blank" rel="nofollow">Non-Tech City</a><br /><a href="http://non-tech-city.com/" target="_blank" rel="nofollow">Matthew Sparkes</a>

- 0

Yeah, that would be fine, but my math is a little rusty.

What sort of code would be needed if I had x,y as starts points, l as length of line, and a as angle?

I could then take this, and run through th array, adding the coordinates next to the angle, adding the coordinate of point 2 to that of point 1 and so on.

What sort of code would be needed if I had x,y as starts points, l as length of line, and a as angle?

I could then take this, and run through th array, adding the coordinates next to the angle, adding the coordinate of point 2 to that of point 1 and so on.

Keith Lynn

Ranch Hand

Posts: 2399

posted 9 years ago

- 0

Well remember that in a right triangle, if the hypotenuse is of length l, and one of the acute angles is a, then the length of the side adjacent is l*cos(a), and the length of the side opposite it is l*sin(a). Remember that in Java, Math.sin and Math.cos expect radian values and there are pi radians in a semicircle.

Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |