Begin forwarded message: > Date: Tue, 25 Oct 2016 08:32:04 0000 > From: [hidden email] > To: [hidden email], [hidden email] > Reply-To: [hidden email] > Subject: The Trunk: EToys-tfel.270.mcz > Message-Id: <E1byx9V-0003nR-6N@andreas> > > Tim Felgentreff uploaded a new version of EToys to project The Trunk: > http://source.squeak.org/trunk/EToys-tfel.270.mcz > > ==================== Summary ==================== > > Name: EToys-tfel.270 > Author: tfel > Time: 24 October 2016, 1:35:27.841614 pm > UUID: 932b296e-7b57-1845-b76e-2dcfde371c97 > Ancestors: EToys-tfel.269 > > allow distance/angleTo my own turtle kind, excepting myself > > =============== Diff against EToys-tfel.269 =============== > > Item was changed: > ----- Method: KedamaTurtleVectorPlayer2 class>>primGetAngleToX:toY:xArray:yArray:resultInto: (in category 'as yet unclassified') ----- > primGetAngleToX: pX toY: pY xArray: xArray yArray: yArray resultInto: result > > + | ppx ppy x y ret currentDist minDist nearestNeighbour skipSelf | > - | ppx ppy x y ret currentDist minDist nearestNeighbour | > <primitive: 'vectorGetAngleTo' module:'KedamaPlugin2'> > "^ KedamaPlugin doPrimitive: #vectorGetAngleTo." > > ppx := pX. > ppy := pY. > + skipSelf := pX == xArray. > 1 to: result size do: [:index | > pX isCollection ifTrue: [ > + nearestNeighbour := index. > minDist := SmallInteger maxVal. > 1 to: pX size do: [:index2 | > + ((index2 == index) & skipSelf) ifFalse: [ > + ppx := pX at: index2. > + ppy := pY at: index2. > + currentDist := ((ppx - (xArray at: index)) squared + (ppy - (yArray at: index)) squared) sqrt. > + currentDist < minDist ifTrue: [ > + minDist := currentDist. > + nearestNeighbour := index2]]]. > - ppx := pX at: index2. > - ppy := pY at: index2. > - currentDist := ((ppx - (xArray at: index)) squared + (ppy - (yArray at: index)) squared) sqrt. > - currentDist < minDist ifTrue: [ > - minDist := currentDist. > - nearestNeighbour := index2]]. > ppx := pX at: nearestNeighbour. > ppy := pY at: nearestNeighbour. > ]. > x := ppx - (xArray at: index). > y := ppy - (yArray at: index). > ret := (x@y) theta radiansToDegrees + 90.0. > ret > 360.0 ifTrue: [ret := ret - 360.0]. > result at: index put: ret. > ]. > ^ result. > ! > > Item was changed: > ----- Method: KedamaTurtleVectorPlayer2 class>>primGetDistanceToX:toY:xArray:yArray:resultInto: (in category 'as yet unclassified') ----- > primGetDistanceToX: pX toY: pY xArray: xArray yArray: yArray resultInto: result > > + | ppx ppy tempMin skipSelf | > - | ppx ppy tempMin | > <primitive: 'vectorGetDistanceTo' module:'KedamaPlugin2'> > "^ KedamaPlugin doPrimitive: #vectorGetDistanceTo." > > ppx := pX. > ppy := pY. > + skipSelf := pX == xArray. > 1 to: result size do: [:index | > pX isCollection ifTrue: [ > tempMin := SmallInteger maxVal. > 1 to: pX size do: [:index2 | > + ((index2 == index) & skipSelf) ifFalse: [ > + ppx := pX at: index2. > + ppy := pY at: index2. > + tempMin := tempMin min: ((ppx - (xArray at: index)) squared + (ppy - (yArray at: index)) squared) sqrt] > - ppx := pX at: index2. > - ppy := pY at: index2. > - tempMin := tempMin min: ((ppx - (xArray at: index)) squared + (ppy - (yArray at: index)) squared) sqrt. > ]. > self flag: #todo. "should really also remember the other side index to re-use inside the script" > result at: index put: tempMin. > ] ifFalse: [ > result at: index put: ((ppx - (xArray at: index)) squared + (ppy - (yArray at: index)) squared) sqrt. > ] > ]. > ^ result. > ! > > Item was changed: > ----- Method: KedamaTurtleVectorPlayer2>>getAngleTo: (in category 'player commands') ----- > getAngleTo: players > > | p xArray yArray result pX pY xy | > players isCollection ifFalse: [ > p := players > ]. > xArray := arrays at: 2. > yArray := arrays at: 3. > result := KedamaFloatArray new: self size. > players isCollection ifTrue: [ > pX := KedamaFloatArray new: players size. > pY := KedamaFloatArray new: players size. > 1 to: players size do: [:i | > xy := (players at: i) getXAndY. > pX at: i put: xy x. > pY at: i put: xy y. > ]. > ] ifFalse: [ > + p == self > + ifTrue: [ > + pX := p getX. > + pY := p getY] > + ifFalse: [ > + pX := p turtles getX. > + pY := p turtles getY] > - pX := p turtles getX. > - pY := p turtles getY. > ]. > ^ KedamaTurtleVectorPlayer2 primGetAngleToX: pX toY: pY xArray: xArray yArray: yArray resultInto: result. > > ! > > Item was changed: > ----- Method: KedamaTurtleVectorPlayer2>>getDistanceTo: (in category 'player commands') ----- > getDistanceTo: players > > | p xArray yArray result pX pY xy | > players isCollection ifFalse: [ > p := players > ]. > xArray := arrays at: 2. > yArray := arrays at: 3. > result := KedamaFloatArray new: self size. > players isCollection ifTrue: [ > pX := KedamaFloatArray new: players size. > pY := KedamaFloatArray new: players size. > 1 to: players size do: [:i | > xy := (players at: i) getXAndY. > pX at: i put: xy x. > pY at: i put: xy y. > ]. > ] ifFalse: [ > + p == self > + ifTrue: [ > + pX := p getX. > + pY := p getY] > + ifFalse: [ > + pX := p turtles getX. > + pY := p turtles getY] > - pX := p turtles getX. > - pY := p turtles getY. > ]. > ^ KedamaTurtleVectorPlayer2 primGetDistanceToX: pX toY: pY xArray: xArray yArray: yArray resultInto: result. > ! > |
Free forum by Nabble | Edit this page |