Squeak Class Documentation category index | class index  
 
Point
  category: Graphics-Primitives
  superclass: Object
  subclasses: POVertex

I represent an x-y pair of numbers usually designating a location on the screen.

instance methods
  accessing
  x
y

  arithmetic
  *
+
-
/
//
\\
abs

  as yet unclassified
  encodeForRemoteCanvas

  comparing
  <
<=
=
>
>=
hash
hashMappedBy:
max:
min:
min:max:

  converting
  @
adaptToCollection:andSend:
adaptToNumber:andSend:
adaptToString:andSend:
asFloatPoint
asIntegerPoint
asPoint
corner:
extent:
isPoint
rect:

  copying
  deepCopy
veryDeepCopyWith:

  geometry
  isInsideCircle:with:with:
sideOf:
to:intersects:to:
to:sideOf:
triangleArea:with:

  interpolating
  interpolateTo:at:

  point functions
  bearingToPoint:
crossProduct:
dist:
dotProduct:
eightNeighbors
flipBy:centerAt:
fourNeighbors
grid:
insideTriangle:with:with:
nearestPointAlongLineFrom:to:
nearestPointOnLineFrom:to:
normal
normalized
octantOf:
onLineFrom:to:
onLineFrom:to:within:
quadrantOf:
rotateBy:centerAt:
sortsBefore:
squaredDistanceTo:
transposed

  polar coordinates
  degrees
r
theta

  printing
  basicType
encodePostscriptOn:
printOn:
storeOn:

  private
  bitShiftPoint:
setR:degrees:
setX:setY:

  testing
  isZero

  transforming
  adhereTo:
negated
rotateBy:about:
scaleBy:
scaleFrom:to:
translateBy:

  truncation and round off
  rounded
truncateTo:
truncated

class methods
  instance creation
  fromUser
r:degrees:
x:y:

instance methods
  accessing top  
 

x

Answer the x coordinate.


 

y

Answer the y coordinate.


  arithmetic top  
 

*

Answer a Point that is the product of the receiver and arg.


 

+

Answer a Point that is the sum of the receiver and arg.


 

-

Answer a Point that is the difference of the receiver and arg.


 

/

Answer a Point that is the quotient of the receiver and arg.


 

//

Answer a Point that is the quotient of the receiver and arg.


 

\\

Answer a Point that is the mod of the receiver and arg.


 

abs

Answer a Point whose x and y are the absolute values of the receiver's x
and y.


  as yet unclassified top  
 

encodeForRemoteCanvas


  comparing top  
 

<

Answer whether the receiver is above and to the left of aPoint.


 

<=

Answer whether the receiver is neither below nor to the right of aPoint.


 

=

Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.


 

>

Answer whether the receiver is below and to the right of aPoint.


 

>=

Answer whether the receiver is neither above nor to the left of aPoint.


 

hash

Hash is reimplemented because = is implemented.


 

hashMappedBy:

My hash is independent of my oop.


 

max:

Answer the lower right corner of the rectangle uniquely defined by the
receiver and the argument, aPoint.


 

min:

Answer the upper left corner of the rectangle uniquely defined by the
receiver and the argument, aPoint.


 

min:max:


  converting top  
 

@


 

adaptToCollection:andSend:

If I am involved in arithmetic with a Collection, return a Collection of
the results of each element combined with me in that expression.


 

adaptToNumber:andSend:

If I am involved in arithmetic with an Integer, convert it to a Point.


 

adaptToString:andSend:

If I am involved in arithmetic with a String, convert it to a Number.


 

asFloatPoint


 

asIntegerPoint


 

asPoint

Answer the receiver itself.


 

corner:

Answer a Rectangle whose origin is the receiver and whose corner is
aPoint. This is one of the infix ways of expressing the creation of a
rectangle.


 

extent:

Answer a Rectangle whose origin is the receiver and whose extent is
aPoint. This is one of the infix ways of expressing the creation of a
rectangle.


 

isPoint

Overridden to return true in Point.


 

rect:

Answer a Rectangle that encompasses the receiver and aPoint.
This is the most general infix way to create a rectangle.


  copying top  
 

deepCopy

Implemented here for better performance.


 

veryDeepCopyWith:

Return self. I am immutable in the Morphic world. Do not record me.


  geometry top  
 

isInsideCircle:with:with:

Returns TRUE if self is inside the circle defined by the
points a, b, c. See Guibas and Stolfi (1985) p.107


 

sideOf:

Returns #left, #right or #center if the otherPoint lies to the left, right
or on the line given by the vector from 0@0 to self


 

to:intersects:to:

Returns true if the linesegment from start1 (=self) to end1 intersects
with the segment from start2 to end2, otherwise false.


 

to:sideOf:

Returns #left, #right, #center if the otherPoint lies to the left, right or on the line given by the vector from self to end


 

triangleArea:with:

Returns twice the area of the oriented triangle (a, b, c), i.e., the
area is positive if the triangle is oriented counterclockwise


  interpolating top  
 

interpolateTo:at:

Interpolate between the instance and end after the specified amount has been done (0 - 1).


  point functions top  
 

bearingToPoint:

Return the bearing, in degrees, from the receiver to anotherPoint.
Adapted from Playground, where the ultimate provenance of the algorithm was a wild earlier method of Jay Fenton's which I never checked carefully, but the thing has always seemed to work


 

crossProduct:

Answer a number that is the cross product of the receiver and the
argument, aPoint.


 

dist:

Answer the distance between aPoint and the receiver.


 

dotProduct:

Answer a number that is the dot product of the receiver and the
argument, aPoint. That is, the two points are multipled and the
coordinates of the result summed.


 

eightNeighbors


 

flipBy:centerAt:

Answer a Point which is flipped according to the direction about the point c.
Direction must be #vertical or #horizontal.


 

fourNeighbors


 

grid:

Answer a Point to the nearest rounded grid modules specified by aPoint.


 

insideTriangle:with:with:

Return true if the receiver is within the triangle defined by the three coordinates.
Note: This method computes the barycentric coordinates for the receiver and tests those coordinates.


 

nearestPointAlongLineFrom:to:

Note this will give points beyond the endpoints.
Streamlined by Gerardo Richarte 11/3/97


 

nearestPointOnLineFrom:to:

This will not give points beyond the endpoints


 

normal

Answer a Point representing the unit vector rotated 90 deg clockwise.


 

normalized

Optimized for speed -- ar 8/26/2001


 

octantOf:

Return 1..8 indicating relative direction to otherPoint.
1=ESE, 2=SSE, ... etc. clockwise to 8=ENE


 

onLineFrom:to:


 

onLineFrom:to:within:

Answer true if the receiver lies on the given line segment between p1 and p2 within a small epsilon.


 

quadrantOf:

Return 1..4 indicating relative direction to otherPoint.
1 is downRight, 2=downLeft, 3=upLeft, 4=upRight


 

rotateBy:centerAt:

Answer a Point which is rotated according to direction, about the point c.
Direction must be one of #right (CW), #left (CCW) or #pi (180 degrees).


 

sortsBefore:

Return true if the receiver sorts before the other point


 

squaredDistanceTo:

Answer the distance between aPoint and the receiver.


 

transposed


  polar coordinates top  
 

degrees

Answer the angle the receiver makes with origin in degrees. right is 0; down is 90.


 

r

Answer the receiver's radius in polar coordinate system.


 

theta

Answer the angle the receiver makes with origin in radians. right is 0;
down is 90.


  printing top  
 

basicType

Answer a symbol representing the inherent type of the receiver


 

encodePostscriptOn:


 

printOn:

The receiver prints on aStream in terms of infix notation.


 

storeOn:

x@y printed form is good for storing too


  private top  
 

bitShiftPoint:


 

setR:degrees:


 

setX:setY:


  testing top  
 

isZero


  transforming top  
 

adhereTo:

If the receiver lies outside aRectangle, return the nearest point on the boundary of the rectangle, otherwise return self.


 

negated

Answer a point whose x and y coordinates are the negatives of those of the receiver. 6/6/96 sw


 

rotateBy:about:

Even though Point.theta is measured CW, this rotates with the more conventional CCW interpretateion of angle.


 

scaleBy:

Answer a Point scaled by factor (an instance of Point).


 

scaleFrom:to:

Produce a point stretched according to the stretch from rect1 to rect2


 

translateBy:

Answer a Point translated by delta (an instance of Point).


  truncation and round off top  
 

rounded

Answer a Point that is the receiver's x and y rounded. Answer the receiver if its coordinates are already integral.


 

truncateTo:

Answer a Point that is the receiver's x and y truncated to grid x and
grid y.


 

truncated

Answer a Point whose x and y coordinates are integers. Answer the receiver if its coordinates are already integral.


class methods
  instance creation top  
 

fromUser


 

r:degrees:

Answer an instance of me with polar coordinates rho and theta.


 

x:y:

Answer an instance of me with coordinates xInteger and yInteger.