X-Git-Url: https://git.llucax.com/z.facultad/75.68/celdas.git/blobdiff_plain/d605ed0d8da75888ee78a87cd817d5227668867a..02829c0a943fc03f7b6c85d18d2d210395f05086:/trunk/src/breve/Celdas.tz diff --git a/trunk/src/breve/Celdas.tz b/trunk/src/breve/Celdas.tz index a8a65f4..b9a63fb 100644 --- a/trunk/src/breve/Celdas.tz +++ b/trunk/src/breve/Celdas.tz @@ -4,8 +4,6 @@ @use Link. @use MultiBody. -@define CELDAS_MAX_VELOCITY 30. - PhysicalControl : CeldasControl { % This class is used for building simple vehicle % simulations. To create a vehicle simulation, @@ -188,10 +186,6 @@ Link : CeldasWheel (aka CeldasWheels) { + variables: joint (object). - velocity (float). - - + to init: - velocity = 0. - to set-joint to j (object): % Used internally. @@ -203,15 +197,12 @@ Link : CeldasWheel (aka CeldasWheels) { + to set-velocity to n (float): % Sets the velocity of this wheel. - if n > CELDAS_MAX_VELOCITY: n = CELDAS_MAX_VELOCITY. - velocity = n. - - joint set-joint-velocity to velocity. + joint set-joint-velocity to n. + to get-velocity: % Gets the velocity of this wheel. - return velocity. + return (joint get-joint-velocity). } @@ -248,6 +239,8 @@ Link : CeldasSensor (aka CeldasSensors) { % if not, the sensor reading correspond to the previous % iteration. + return value. + + to iterate: i (object). strength, angle (float). @@ -263,9 +256,7 @@ Link : CeldasSensor (aka CeldasSensors) { if angle < sensorAngle: { strength = | (self get-location) - (i get-location) |. - strength = 1.0 / (strength * strength) . - - if strength > 10: strength = 10. + strength = 100.0 / (strength * strength) . if strength > value: value = strength. }