Back: PluggableProxy-saving and restoring
Up: Class reference
Forward: Point class-instance creation
 
Top: GNU Smalltalk User's Guide
Contents: Table of Contents
Index: Class index
About: About this document

6.112 Point

Defined in namespace Smalltalk
Category: Language-Data types
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.

6.112.1 Point class: instance creation  (class)
6.112.2 Point: accessing  (instance)
6.112.3 Point: arithmetic  (instance)
6.112.4 Point: comparing  (instance)
6.112.5 Point: converting  (instance)
6.112.6 Point: point functions  (instance)
6.112.7 Point: printing  (instance)
6.112.8 Point: storing  (instance)
6.112.9 Point: truncation and round off  (instance)


6.112.1 Point class: instance creation

new
Create a new point with both coordinates set to 0

x: xInteger y: yInteger
Create a new point with the given coordinates


6.112.2 Point: accessing

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


6.112.3 Point: arithmetic

* 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


6.112.4 Point: comparing

< 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


6.112.5 Point: converting

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


6.112.6 Point: point functions

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)


6.112.7 Point: printing

printOn: aStream
Print a representation for the receiver on aStream


6.112.8 Point: storing

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


6.112.9 Point: truncation and round off

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)




This document was generated on May, 12 2002 using texi2html