|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--robi.sim.objects.SimSensor
| Field Summary | |
double |
d
Direction of sensor |
double |
direction
Start direction of sensor |
boolean |
isThRunning
Indicates whether the sensor thread is running or not |
java.awt.Point |
p
Position of sensor |
SimRobot |
robo
SimRobot object where this sensor is set on |
java.awt.Point |
startPos
Start position of sensor |
java.lang.Thread |
thUpdate
Update thread |
int |
value
Sensor value of this sensor |
| Constructor Summary | |
SimSensor(int x,
int y,
double di,
SimRobot r)
|
|
| Method Summary | |
private double |
calcSensorValue(int xLight,
int yLight,
int val)
Calculates sensor value (for one light) |
private double |
getAngle(int xLight,
int yLight)
Calculates the angle between light and sensor |
private int |
getDistance(int xLight,
int yLight)
Calculates distance between light and sensor |
private double |
getPercentFromAngle(double angle)
Special function to calculate percentage from an angle |
private double |
getPercentFromDistance(int dist)
Special function to calculate percentage from a distance |
int |
getSensorValue()
Returns sensor vlaue |
private int |
getSensorValue(java.util.Vector lights)
Calculates sensor values (for all lights) |
void |
run()
Main method of update thread which updates the sensor value |
void |
start()
Starts the sensor thread |
void |
stop()
Stops the sensor thread |
void |
updatePos()
Updates position of sensor |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public boolean isThRunning
public java.awt.Point startPos
public double direction
public SimRobot robo
public int value
public java.lang.Thread thUpdate
public java.awt.Point p
public double d
| Constructor Detail |
public SimSensor(int x,
int y,
double di,
SimRobot r)
| Method Detail |
public void start()
public void stop()
public void run()
run in interface java.lang.Runnablepublic int getSensorValue()
private int getSensorValue(java.util.Vector lights)
lights - All lights in simulation
public void updatePos()
private double calcSensorValue(int xLight,
int yLight,
int val)
xLight - x coordinate of lightyLight - y coordiante of lightval - light value
private double getAngle(int xLight,
int yLight)
xLight - x coordinate of lightyLight - y coordinate of light
private int getDistance(int xLight,
int yLight)
xLight - x coordinate of lightyLight - y coordinate of light
private double getPercentFromAngle(double angle)
angle - Calculated angle
private double getPercentFromDistance(int dist)
dist - Calculated distance
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||