All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class primitives.machines.NarmsMachine

java.lang.Object
   |
   +----primitives.machines.Machine
           |
           +----primitives.machines.NarmsMachine

public class NarmsMachine
extends Machine
A spider machnine with varying number of arms.


Variable Index

 o arms
Number of arms of the machine.
 o center
The integral representation of the central joint.
 o dCenter
The central joint.
 o in
 o origin
The location of equal distances from all anchors.
 o tempCenter
A backup for the central joint.

Constructor Index

 o NarmsMachine(Dimension, int, double)

Method Index

 o armStreched(int)
 o finalize()
Sets object fields to null.
 o findConstraintAngles()
 o findConstraints()
Return a Polyogn objects which locations are the locations of the central joint in which 2 adjacent arms are streched out.
 o findConstraintsEx()
Returns the locations of the central joint in which adjacent arms are streched.
 o getCurrentAngle()
 o getJoint(int)
Returns the integral location of an indexed joint.
 o getJointEx(int)
Returns the location of an indexed joint.
 o getMaxDistance(double)
 o getMaxPoint(double)
Returns the extremum location of the central joint from the origin in direction specified by the angle.
 o getRatioDistance(double)
 o moveCenter(double, double)
Conditionaly moves the machine by setting a new location for the central joint.
 o moveCenterEx(double, double)
moves the machine by setting a new location for the central joint The method will always change the position of the machine.
 o moveJointsA()
calculates the location of the periferial joints by the current location of the central joint.
 o moveJointsEx()
calculates the locations of the periferial joint has the same effect as moveJointsA.
 o moveToMaxCoordinate(Coordinate)
Moves the central joint to an extermum location in the direction of a given location.
 o redraw(Graphics)
Draws this machine.
 o restorePoints()
 o rotateCenter(int, double)
conditionaly rotates the central joint.
 o rotateCenterA(int, double)
rotates the central joint with respect to the i,i>th joint.
 o rotateCenterEx(int, double)
rotates the central joint with respect to the i,i>th joint.
 o savePoints()
 o strechArm(int)
strech the given arm
 o switchBend(int)
Switch the bending of a given periferial joint with respect to the central joint and its anchor.

Variables

 o dCenter
 protected Coordinate dCenter
The central joint.

 o center
 public ExtPoint center
The integral representation of the central joint.

 o tempCenter
 public Coordinate tempCenter
A backup for the central joint.

 o arms
 public int arms
Number of arms of the machine.

 o origin
 public Coordinate origin
The location of equal distances from all anchors.

 o in
 private Coordinate in

Constructors

 o NarmsMachine
 public NarmsMachine(Dimension d,
                     int arms,
                     double ratio)
Parameters:
the - size of the rectangle the machine should be drawn in.
arms - number of arms of the machine.
ration - the ratio between the distance between the anchors and the origin and the length of the bars. should me greater then 1.

Methods

 o getCurrentAngle
 public double getCurrentAngle()
 o getRatioDistance
 public double getRatioDistance(double angle)
Returns:
the ratio between the distance between the origin and the location of the current location of the central joint and the maximum distance between these locations. param angle the angle with which to calculate the ratio.
See Also:
getMaxDistance
 o getMaxDistance
 public double getMaxDistance(double angle)
Parameters:
angle - the angle to calculate for which to calculate the distance.
Returns:
the maximum possible distance between the origin and the location of the central joint for a given angle.
 o getMaxPoint
 public Coordinate getMaxPoint(double angle)
Returns the extremum location of the central joint from the origin in direction specified by the angle. An approximation algorithm is used.

Parameters:
angle - the angle to use.
Returns:
the extremum location
 o moveToMaxCoordinate
 public int moveToMaxCoordinate(Coordinate newP)
Moves the central joint to an extermum location in the direction of a given location.

Parameters:
newP - the given location.
Returns:
0
 o findConstraints
 public Polygon findConstraints()
Return a Polyogn objects which locations are the locations of the central joint in which 2 adjacent arms are streched out.

 o findConstraintsEx
 public Coordinate[] findConstraintsEx()
Returns the locations of the central joint in which adjacent arms are streched.

Returns:
an array of the locations.
See Also:
findConstraints
 o findConstraintAngles
 public Coordinate[] findConstraintAngles()
See Also:
findConstraintsEx
 o redraw
 public void redraw(Graphics g)
Draws this machine.

Parameters:
g - the graphic context to draw on.
Overrides:
redraw in class Machine
 o savePoints
 protected void savePoints()
Overrides:
savePoints in class Machine
See Also:
savePoints
 o restorePoints
 protected void restorePoints()
Overrides:
restorePoints in class Machine
See Also:
restorePoints
 o moveJointsA
 private int[] moveJointsA()
calculates the location of the periferial joints by the current location of the central joint.

Returns:
an array of integers if arm i is streched the i location in the array is 1 else is 0.
 o getJoint
 public Point getJoint(int i)
Returns the integral location of an indexed joint.

Parameters:
i - the index of the joint to return
Returns:
the integral representation of the joint
 o getJointEx
 public Coordinate getJointEx(int i)
Returns the location of an indexed joint.

Parameters:
i - the index of the joint to return
Returns:
the location of the joint.
 o rotateCenterA
 public int[] rotateCenterA(int i,
                            double dalpha)
rotates the central joint with respect to the i,i>th joint.

Parameters:
i - the index of the joint.
dalpha - the rotation angle.
Returns:
an array of 0 or 1, for each arm 1 if the rotation caused the arm to strech, 0 if not.
 o moveJointsEx
 private int moveJointsEx()
calculates the locations of the periferial joint has the same effect as moveJointsA.

Returns:
the index of the last arm which had been streched due its new location.
 o moveCenterEx
 public int moveCenterEx(double dx,
                         double dy)
moves the machine by setting a new location for the central joint The method will always change the position of the machine. use moveCenter to conditionaly move the machine.

Parameters:
dx - the amount to move the center in the horizontal direction.
dy - the amount to move the center in the vertical direction.
Returns:
the index of the last joint which was streched by activating this method.
See Also:
moveCenter
 o moveCenter
 public void moveCenter(double dx,
                        double dy) throws MachineException
Conditionaly moves the machine by setting a new location for the central joint.

Parameters:
dx - the amount to move the center in the horizontal direction.
dy - the amount to move the center in the vertical direction.
Throws: MachineException
if the new state is not physicaly allowed. see #moveCenterEx
 o rotateCenterEx
 public int rotateCenterEx(int i,
                           double dalpha)
rotates the central joint with respect to the i,i>th joint.

Parameters:
i - the index of the joint.
dalpha - the rotation angle.
Returns:
the index of the last joint to strech.
 o rotateCenter
 public void rotateCenter(int i,
                          double dalpha) throws MachineException
conditionaly rotates the central joint.

Throws: MachineException
if the rotation is not physicaly possible.
See Also:
rotateCenterEx
 o switchBend
 public void switchBend(int i)
Switch the bending of a given periferial joint with respect to the central joint and its anchor.

Parameters:
i - the index of the joint to strech.
 o strechArm
 public void strechArm(int arm)
strech the given arm

 o armStreched
 public boolean armStreched(int i)
Parameters:
i - the index of the arm.
Returns:
true if arm i is streched.
 o finalize
 public void finalize() throws Throwable
Sets object fields to null.

Throws: Throwable
.
Overrides:
finalize in class Machine

All Packages  Class Hierarchy  This Package  Previous  Next  Index