The comment for class LinearFit (a subclass of Path) says :
"I represent a piece-wise linear approximation to a set of points in the plane."
Is this a correct statement?
I think that the author was thinking about a linear interpolation problem. In these problems you want the graph of a function, but you only have some points of it. A linear interpolation is obtained joining the points with segments.
Hope this helps Leandro
Piecewise-linear approximation normally means the best fit of a set of points by a continuous series of straight line segments. Usually, the condition would be a maximum acceptable deviation and 'optimal' would mean the least possible number of segments..
Date forwarded: 24 Nov 1998 22:49:51 -0000 Send reply to: "Leandro Caniglia" caniglia@dm.uba.ar From: "Leandro Caniglia" caniglia@dm.uba.ar To: squeak@cs.uiuc.edu Subject: Re: Class LinearFit - What does the comment mean? Date sent: Tue, 24 Nov 1998 19:41:49 -0300 Forwarded by: squeak@cs.uiuc.edu
The comment for class LinearFit (a subclass of Path) says :
"I represent a piece-wise linear approximation to a set of points in the plane."
Is this a correct statement?
I think that the author was thinking about a linear interpolation problem. In these problems you want the graph of a function, but you only have some points of it. A linear interpolation is obtained joining the points with segments.
Hope this helps Leandro
Ivan Tomek, Jodrey School of Computer Science Acadia University Nova Scotia, Canada fax: (902) 585-1067 voice: (902) 585-1467
I was working on some graphics code last night and found what I think is a problem in the Path hierarchy.
The original methods collect: and select: tried to send the message form: to newCollection. The method form: is a Path instance message; it is not understood by collection.
The original method displayOn: transformation: clippingBox: rule: fillColor: sent the message do: to transformedPath. The message collect: should be used instead.
In addition to the code fix, I am suggesting a modification to the comment associated with LinearFit. The definitions I got from Ivan Tomek and Leandro Caniglia were very helpful.
original comment: "I represent a piece-wise linear approximation to a set of points in the plane."
revised comment: "I represent a piecewise-linear approximation to a set of points on a plane. A piecewise-linear approximation is the best fit of a set of points by a continuous series of straight line segments. A square is an example of a piecewise-liner approximation of a circle."
'From Squeak 2.2 of Sept 23, 1998 on 24 November 1998 at 10:36:51 pm'! !Path methodsFor: 'enumerating'! collect: aBlock "Evaluate aBlock for each point in the receiver's collectionOfPoints. Answer with a new collection."
| newCollection | newCollection _ collectionOfPoints collect: aBlock. ^newCollection! ! !Path methodsFor: 'enumerating'! select: aBlock "Evaluate aBlock for each point in the receiver's collectionOfPoints. Answer with a new collection."
| newCollection | newCollection _ collectionOfPoints select: aBlock. ^newCollection! ! !LinearFit methodsFor: 'displaying'! displayOn: aDisplayMedium transformation: aTransformation clippingBox: clipRect rule: anInteger fillColor: aForm
"Create a new LinearFit and apply aTransformation to the collectionOfPoints. Display the new LinearFit." | newLinearFit transformedPath | transformedPath _ aTransformation applyTo: self. newLinearFit _ LinearFit new. transformedPath collect: [:point | newLinearFit add: point]. newLinearFit form: self form. newLinearFit displayOn: aDisplayMedium at: 0 @ 0 clippingBox: clipRect rule: anInteger fillColor: aForm! !
squeak-dev@lists.squeakfoundation.org