Category: Language-Data types
Superclass: Object
Beginning of a Point class for simple display manipulation. Has not been exhaustively tested but appears to work for the basic primitives and for the needs of the Rectangle class.

Method category index

instance creation (class)
accessing (instance)
arithmetic (instance)
comparing (instance)
converting (instance)
point functions (instance)
printing (instance)
storing (instance)
truncation and round off (instance)

instance creation (class)

new
Create a new point with both coordinates set to 0

x: xInteger y: yInteger

Create a new point with the given coordinates

top


accessing (instance)

x
Answer the x coordinate

x: aNumber

Set the x coordinate to aNumber

x: anXNumber y: aYNumber

Set the x and y coordinate to anXNumber and aYNumber, respectively

y

Answer the y coordinate

y: aNumber

Set the y coordinate to aNumber

top


arithmetic (instance)

* scale
Multiply the receiver by scale, which can be a Number or a Point

+ delta

Sum the receiver and delta, which can be a Number or a Point

- delta

Subtract delta, which can be a Number or a Point, from the receiver

/ scale

Divide the receiver by scale, which can be a Number or a Point, with no loss of precision

// scale

Divide the receiver by scale, which can be a Number or a Point, with truncation towards -infinity

abs

Answer a new point whose coordinates are the absolute values of the receiver's

top


comparing (instance)

< aPoint
Answer whether the receiver is higher and to the left of aPoint

<= aPoint

Answer whether aPoint is equal to the receiver, or the receiver is higher and to the left of aPoint

= aPoint

Answer whether the receiver is equal to aPoint

> aPoint

Answer whether the receiver is lower and to the right of aPoint

>= aPoint

Answer whether aPoint is equal to the receiver, or the receiver is lower and to the right of aPoint

max: aPoint

Answer self if it is lower and to the right of aPoint, aPoint otherwise

min: aPoint

Answer self if it is higher and to the left of aPoint, aPoint otherwise

top


converting (instance)

asPoint
Answer the receiver.

asRectangle

Answer an empty rectangle whose origin is self

corner: aPoint

Answer a Rectangle whose origin is the receiver and whose corner is aPoint

extent: aPoint

Answer a Rectangle whose origin is the receiver and whose extent is aPoint

hash

Answer an hash value for the receiver

top


point functions (instance)

arcTan
Answer the angle (measured counterclockwise) between the receiver and a ray starting in (0, 0) and moving towards (1, 0) - i.e. 3 o'clock

dist: aPoint

Answer the distance between the receiver and aPoint

dotProduct: aPoint

Answer the dot product between the receiver and aPoint

grid: aPoint

Answer a new point whose coordinates are rounded towards the nearest multiple of aPoint

normal

Rotate the Point 90degrees clockwise and get the unit vector

transpose

Answer a new point whose coordinates are the receiver's coordinates exchanged (x becomes y, y becomes x)

truncatedGrid: aPoint

Answer a new point whose coordinates are rounded towards -infinity, to a multiple of grid (which must be a Point)

top


printing (instance)

printOn: aStream
Print a representation for the receiver on aStream

top


storing (instance)

storeOn: aStream
Print Smalltalk code compiling to the receiver on aStream

top


truncation and round off (instance)

rounded
Answer a new point whose coordinates are rounded to the nearest integer

truncateTo: grid

Answer a new point whose coordinates are rounded towards -infinity, to a multiple of grid (which must be a Number)

top