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: 140

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: Spring Reads Data
Rating: 5.625
Filesize: 12.07 kB
Downloads: 3103
Comments: 23
Ratings: 2
Date added: 2021/10/08 23:42:15
Made with: Algodoo v2.1.0
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: turret defense
Rating: 4.7273
Filesize: 426.98 kB
Downloads: 725
Comments: 2
Ratings: 5
Date added: 2009/04/05 14:11:17
Made with: Phun
Rating: rated 4.7
download
Title: Simple Computer
Rating: 5.25
Filesize: 11.77 kB
Downloads: 2631
Comments: 0
Ratings: 2
Date added: 2023/07/05 09:51:37
Made with: Algodoo v2.1.0
Rating: rated 5.3
download
Title: Zero Length Spring Equivalent
Rating: 5
Filesize: 41.62 kB
Downloads: 442
Comments: 3
Ratings: 1
Date added: 2023/06/09 01:07:17
Made with: Algodoo v2.1.0
Rating: rated 5
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
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