|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object TGPoint
public class TGPoint
A TGPoint is a virtual point, a point in TurtleSpace. In TurtleSpace, 0.0,0.0 is at the center of the graphics canvas, like the way coordinate spaces are represented in Algebra. Likewise, TGPoints have appoximated real number coordinates. TGPoints may or may not be visible based upon the current size of the graphics canvas window of TG. Methods are provided to map the point's coordinates from TurtleSpace to an Image's x and y indicies.
TurtleGraphics now works entirely with TGPoints - points in TurtleSpace. Early versions of TG used int primitive values for X and Y coordinates. This approach led to too many visual problems caused by the propagation of rounding off values. TGPoint isolates actual implementation of points to one place which can thus be more easily controlled.
Field Summary | |
---|---|
double |
x
This TGPoint's X coordinate. |
double |
y
This TGPoint's Y coordinate. |
Constructor Summary | |
---|---|
TGPoint()
Default TGPoint is [0,0] which is the center of TurtleSpace. |
|
TGPoint(double x,
double y)
Constructs a new TGPoint (a virtual point in TurtleSpace) based upon provided double values for x and y coordinates. |
|
TGPoint(float x,
float y)
Constructs a new TGPoint (a virtual point in TurtleSpace) based upon provided float values for x and y coordinates. |
|
TGPoint(int x,
int y)
Constructs a new TGPoint (a virtual point in TurtleSpace) based upon provided int values for x and y coordinates. |
|
TGPoint(long x,
long y)
Constructs a new TGPoint (a virtual point in TurtleSpace) based upon provided long values for x and y coordinates. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Creates and returns a copy of this TGPoint. |
boolean |
equals(java.lang.Object obj)
Override Object.equals(Object) so that comparison is based on the x and y fields. |
double |
imageX(double imageWidth)
Return an Image's index equivilent for this point's X coordinate. |
int |
imageX(double offset,
int imageWidth)
Return an Image's index equivilent for this point's X coordinate combined with a provided offset. |
int |
imageX(int imageWidth)
Return an Image's index equivilent for this point's X coordinate. |
double |
imageY(double imageHeight)
Return an Image's index equivilent for this point's Y coordinate. |
int |
imageY(double offset,
int imageHeight)
Return an Image's index equivilent for this point's Y coordinate combined with a provided offset. |
int |
imageY(int imageHeight)
Return an Image's index equivilent for this point's Y coordinate. |
TGPoint |
otherEndPoint(double radians,
double length)
Given one end point of a line, its length and heading (in radians), return its other end point. |
java.lang.String |
toString()
Returns the String representation of this point. |
double |
xDoubleValue()
Returns the X coordinate of this point in double precision. |
long |
xLongValue()
Returns the X coordinate of this point as a long int. |
double |
yDoubleValue()
Returns the Y coordinate of this point in double precision. |
long |
yLongValue()
Returns the Y coordinate of this point as a long int. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final double x
public final double y
Constructor Detail |
---|
public TGPoint()
public TGPoint(double x, double y)
public TGPoint(float x, float y)
public TGPoint(int x, int y)
public TGPoint(long x, long y)
Method Detail |
---|
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public double imageX(double imageWidth)
public int imageX(int imageWidth)
public int imageX(double offset, int imageWidth)
public double imageY(double imageHeight)
public int imageY(int imageHeight)
public int imageY(double offset, int imageHeight)
public java.lang.Object clone()
clone
in class java.lang.Object
public TGPoint otherEndPoint(double radians, double length)
public double xDoubleValue()
public long xLongValue()
public double yDoubleValue()
public long yLongValue()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |