# How to make radial lines come out of one point?

Page 1 of 1

## 1 Replies - 2714 Views - Last Post: 05 October 2010 - 04:25 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=193644&amp;s=971feb34bad5359c43ff1f6c4fe5a7f1&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Cooke3

Reputation: 0
• Posts: 20
• Joined: 24-January 10

# How to make radial lines come out of one point?

Posted 05 October 2010 - 04:07 PM

I am doing a project for school and one part of it needs to made n radial lines (each line is at an angular increment of 2(pi)/n) come out of a point. Eventually the program will have the robot (the point where the lines are coming from) within some polygon (the room) with the radial lines coming out of it and stopping at the edges of the polygon.

So far I'm stuck on how to make the lines, I'm not sure how to do that, other than I would need a for loop.

This is my code so far

```import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class Robot extends Frame
{	public static void main(String[] args){new Robot();}

Robot()
{	super("Robot Range Map");
{public void windowClosing(WindowEvent e){System.exit(0);}});
setSize(600,600);
show();
}
}

class RobotCalc extends Canvas
{	Point pos; //position of robot
int n; // number of sensors
float angle; //angle (2(pi))/n

int iX(float x){return Math.round(x);}

RobotCalc()
pos.x = 350;
pos.y = 222;*/  // test points
}

public void paint (Graphics g)
{	//n = 30; //set direction of robot

//room map, polygon
Polygon room = new Polygon();
g.drawPolygon(room);

//draw the robot, circle with line indicating direction

//drawing n radial lines from robot
for (i=1; i<=n; i++)
{

g.drawLine(pos.x,pos.y,)
}

}
}
```

Is This A Good Question/Topic? 0

## Replies To: How to make radial lines come out of one point?

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 12305
• Posts: 45,401
• Joined: 27-December 08

## Re: How to make radial lines come out of one point?

Posted 05 October 2010 - 04:25 PM

Take a look at the Graphics drawLine() method to handle drawing your lines to the screen. Also, perhaps you may want to look at Polar Coordinates for correct placement of your lines. It is basically an expansion of the Unit Circle, so you'll need some basic Trig as well.