Browse Search Popular Register Upload Rules User list Login:
Search:
Spring reads lineEndPoints' pos

Image:
screenshot of the scene

Author: therestofguys

Group: Default

Filesize: 46.25 kB

Date added: 2024-05-18

Rating: 5

Downloads: 526

Views: 139

Comments: 2

Ratings: 1

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

An example I made for myself.

Reference: http://www.algodoo.com/algobox/details.php?id=244311

----------

In the spring's "postStep":

- Simplified access of the spring's lineEndPoints
endPoint0 = (entityByID((readable(entity)).lineEndPoint0));
endPoint1 = (entityByID((readable(entity)).lineEndPoint1));

- Read the lineEndPoints' pos
_pos0 = endPoint0.pos;
_pos1 = endPoint1.pos;

- Calculates the distance between _pos0 and _pos1
_dist = ((_pos0(0) - _pos1(0)) ^ 2 + (_pos0(1) - _pos1(1)) ^ 2) ^ 0.5;

- Spring size change
size = 1 * _dist;

- Convert _dist's result with 0.5 meter offset to 0.0 ~ 1.0, and limiting it with an if argument with another if argument in its 'else' state
(_dist - 0.5) / 2 < 0 ? {_percent = 0} : {(_dist - 0.5) / 2 < 1 ? {_percent = (_dist - 0.5) / 2} : {_percent = 1}};

- Simplified access to the yellow box lineEndPoint0 is attached to
Box0 = (entityByGeomID((readable(endPoint0)).geom));

- Apply _percent to Box0
Box0.text = {"" + math.ToInt(_percent * 100)}
Last edited at 2024/05/18 13:36:55 by therestofguys
Please log in to rate this scene
edit
Similar scenes
Title: Tachometer for contest
Rating: 6.1111
Filesize: 39.49 kB
Downloads: 1566
Comments: 2
Ratings: 3
Date added: 2009/08/22 02:54:49
Made with: Phun
Rating: rated 6.1
download
Title: Altimeter with Pressure Gauge
Rating: 5.625
Filesize: 14.57 kB
Downloads: 558
Comments: 0
Ratings: 2
Date added: 2010/01/09 16:21:37
Made with: Phun
Rating: rated 5.6
download
Title: H&K 416 V.3
Rating: 4.7
Filesize: 233.59 kB
Downloads: 7116
Comments: 41
Ratings: 4
Date added: 2010/08/17 21:38:39
Made with: Phun
Rating: rated 4.7
download
Title: Snowboard Parachute Adventure!
Rating: 5.25
Filesize: 68.32 kB
Downloads: 1486
Comments: 10
Ratings: 2
Date added: 2009/05/18 01:58:59
Made with: Phun
Rating: rated 5.3
download
Title: Spring rope
Rating: 5
Filesize: 185.48 kB
Downloads: 409
Comments: 0
Ratings: 1
Date added: 2016/07/20 10:27:16
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Radial stabilized engine (0.23 Kn per spring)
Rating: 5
Filesize: 28.12 kB
Downloads: 554
Comments: 0
Ratings: 1
Date added: 2011/05/18 12:57:44
Made with: Algodoo before v1.8.5
Rating: rated 5
download
Good job on the scene! I'm glad to know that someone actually used the information in my scene id=244311. :)
Glad I found it, the scene's method is way simpler than how I was doing it scattering extra scripts in both the endpoint and the spring.:D