This file is indexed.

/usr/share/gnu-smalltalk/kernel/Point.st is in gnu-smalltalk-common 3.2.4-2.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
"=====================================================================
|
|    Point Class Definitions
|
|
 ====================================================================="

"======================================================================
|
| Copyright 1992,94,95,99,2000,2001,2002,2006
| Free Software Foundation, Inc.
| Written by Doug McCallum.
| Additions by Steve Byrne and Paolo Bonzini
|
| This file is part of the GNU Smalltalk class library.
|
| The GNU Smalltalk class library is free software; you can redistribute it
| and/or modify it under the terms of the GNU Lesser General Public License
| as published by the Free Software Foundation; either version 2.1, or (at
| your option) any later version.
| 
| The GNU Smalltalk class library is distributed in the hope that it will be
| useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
| General Public License for more details.
| 
| You should have received a copy of the GNU Lesser General Public License
| along with the GNU Smalltalk class library; see the file COPYING.LIB.
| If not, write to the Free Software Foundation, 59 Temple Place - Suite
| 330, Boston, MA 02110-1301, USA.  
|
 ======================================================================"



Object subclass: Point [
    | x y |
    
    <category: 'Language-Data types'>
    <comment: '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.'>

    Point class >> new [
	"Create a new point with both coordinates set to 0"

	<category: 'instance creation'>
	^self basicNew x: 0 y: 0
    ]

    Point class >> x: xInteger y: yInteger [
	"Create a new point with the given coordinates"

	<category: 'instance creation'>
	^self basicNew x: xInteger y: yInteger
    ]

    printOn: aStream [
	"Print a representation for the receiver on aStream"

	<category: 'printing'>
	aStream
	    print: x;
	    nextPut: $@;
	    print: y
    ]

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

	<category: 'storing'>
	aStream
	    nextPut: $(;
	    store: x;
	    nextPutAll: ' @ ';
	    store: y;
	    nextPut: $)
    ]

    x [
	"Answer the x coordinate"

	<category: 'accessing'>
	^x
    ]

    y [
	"Answer the y coordinate"

	<category: 'accessing'>
	^y
    ]

    x: aNumber [
	"Set the x coordinate to aNumber"

	<category: 'accessing'>
	x := aNumber
    ]

    y: aNumber [
	"Set the y coordinate to aNumber"

	<category: 'accessing'>
	y := aNumber
    ]

    x: anXNumber y: aYNumber [
	"Set the x and y coordinate to anXNumber and aYNumber, respectively"

	<category: 'accessing'>
	x := anXNumber.
	y := aYNumber
    ]

    asPoint [
	<category: 'converting'>
	^self	"But I already AM a point!"
    ]

    hash [
	"Answer an hash value for the receiver"

	<category: 'converting'>
	^self x hash bitXor: self y hash
    ]

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

	<category: 'arithmetic'>
	| deltaPoint |
	deltaPoint := delta asPoint.
	^Point x: self x + deltaPoint x y: self y + deltaPoint y
    ]

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

	<category: 'arithmetic'>
	| deltaPoint |
	deltaPoint := delta asPoint.
	^Point x: self x - deltaPoint x y: self y - deltaPoint y
    ]

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

	<category: 'arithmetic'>
	| scalePoint |
	scalePoint := scale asPoint.
	^Point x: self x * scalePoint x y: self y * scalePoint y
    ]

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

	<category: 'arithmetic'>
	| scalePoint |
	scalePoint := scale asPoint.
	^Point x: self x / scalePoint x y: self y / scalePoint y
    ]

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

	<category: 'arithmetic'>
	| scalePoint |
	scalePoint := scale asPoint.
	^Point x: self x // scalePoint x y: self y // scalePoint y
    ]

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

	<category: 'arithmetic'>
	^Point x: self x abs y: self y abs
    ]

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

	<category: 'truncation and round off'>
	^Point x: self x rounded y: self y rounded
    ]

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

	<category: 'truncation and round off'>
	^Point x: (self x truncateTo: grid) y: (self y truncateTo: grid)
    ]

    = aPoint [
	"Answer whether the receiver is equal to aPoint"

	<category: 'comparing'>
	^aPoint class == Point and: [self x = aPoint x & (self y = aPoint y)]
    ]

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

	<category: 'comparing'>
	^self x < aPoint x and: [self y < aPoint y]
    ]

    > aPoint [
	"Answer whether the receiver is lower and to the right of aPoint"

	<category: 'comparing'>
	^self x > aPoint x and: [self y > aPoint y]
    ]

    <= aPoint [
	"Answer whether aPoint is equal to the receiver, or the receiver
	 is higher and to the left of aPoint"

	<category: 'comparing'>
	^self x <= aPoint x and: [self y <= aPoint y]
    ]

    >= aPoint [
	"Answer whether aPoint is equal to the receiver, or the receiver
	 is lower and to the right of aPoint"

	<category: 'comparing'>
	^self x >= aPoint x and: [self y >= aPoint y]
    ]

    max: aPoint [
	"Answer self if it is lower and to the right of aPoint, aPoint otherwise"

	<category: 'comparing'>
	^(self x max: aPoint x) @ (self y max: aPoint y)
    ]

    min: aPoint [
	"Answer self if it is higher and to the left of aPoint, aPoint otherwise"

	<category: 'comparing'>
	^(self x min: aPoint x) @ (self y min: aPoint y)
    ]

    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"

	<category: 'point functions'>
	^self y arcTan: self x
    ]

    dist: aPoint [
	"Answer the distance between the receiver and aPoint"

	<category: 'point functions'>
	| a b |
	a := self x - aPoint x.
	b := self y - aPoint y.
	^(a squared + b squared) sqrt
    ]

    dotProduct: aPoint [
	"Answer the dot product between the receiver and aPoint"

	<category: 'point functions'>
	^self x * aPoint x + (self y * aPoint y)
    ]

    grid: aPoint [
	"Answer a new point whose coordinates are rounded towards the nearest
	 multiple of aPoint"

	<category: 'point functions'>
	^Point x: (self x roundTo: aPoint x) y: (self y roundTo: aPoint y)
    ]

    normal [
	"Rotate the Point 90degrees clockwise and get the unit vector"

	<category: 'point functions'>
	| len |
	len := (self x squared + self y squared) sqrt.
	^Point x: self y negated / len y: x / len
    ]

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

	<category: 'point functions'>
	^Point x: y y: x
    ]

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

	<category: 'point functions'>
	^Point x: (self x truncateTo: aPoint x) y: (self y truncateTo: aPoint y)
    ]
]



Number extend [

    @ y [
	"Answer a new point whose x is the receiver and whose y is y"

	<category: 'point creation'>
	^Point x: self y: y
    ]

    asPoint [
	"Answer a new point, self @ self"

	<category: 'point creation'>
	^Point x: self y: self
    ]

]