Read values / conditions in Expressions

Hi,
I’m often thinking it would be simpler to make animations if I could define relatationships between objects, and in real-time read it’s status (from Expressions). For example, read the length of a Line (property missing?), or angle between two objects (see example in the picture below).

Fig 1. If I had Read Access to the angle between front and rear, and Read Access to the Length of the ToPath curve, then I could calculate the rotation velocity for each individual wheel in real-time (expression). Also the curvature and the length of the Path could change (via Rhino History) and still be regarded by the calculation.

I realize that an angle between two objects perhaps best would be handled by a third object keeping track of any such “relation-value”, say a new “BongoConnection” component needs to be introduced, but so be it. :slight_smile:

In the meantime, is there any way I could trick Bongo to achieve something like that?

// Rolf

The calculation of an angle between objects is currently feasible by using the WorldAngle parameter (e.g. #hinge 0.WorldAngleZ# - #hinge 1.WorldAngleZ#) as demonstrated here : Angles.3dm (42.3 KB)

The length of a curve can obviously be read manually (by using Rhino’s Length command) and then used as a constant value in an Expression. For reading the length of a varying curve there is no parameter. An object carrying varying History isn’t even considered to be an ‘animated’ object - it does not appear in the Animation Manager - and cannot be used in Expressions.

The use of parameters of non-animated objects, such as the coordinates of a point or the length of a curve (the area of a surface?) may be reflected on. Also the data of morphed objects (curve, surface) can be of interest.

Thank you for the hint about WorldAngle. that helps a lot.

And yes, hopefully object properties are introduced in Bongo 3, that would make Bongo a different game.

// Rolf

When I define an Expression for the rotation of a wheel, then I have the problem that the wheel doesn’t rotate unless some variable value referred to to in the Expression changes.

For example if I enter a total distance to be travelled (toPath length) / circumference (plus a formula for compensating when the vehicle turns), then no rotation of the wheel occurs as long as the path is straight, that is, until the vehicle turns and so the angle variables gets changed values.

It means also that I cannot make the wheels rotate with an Expression if simply entering the value for the (total) number of revolutions (like entered in the X, Y, Z fields on the timeline).

Bug 1?
Is this as expected? Unfortunately this means that the Expressions only works “sometimes” and sometimes not (perhaps a workaround for now could be to tweak Bongo by making something rotate during the animation as to provide with “changing values”).

Bug 2?
I also noticed that if I enter a value in the Rotation property, I do not have access to other object’s Position properties, even if they are accessible in the editor. This also seems odd to me.

Perhaps Bug 1 & 2 could be addressed in a service release? It really would help a lot.

// Rolf

Rolf,
I think you overlooked that and Expression can be joined with actions defined by keyframes.
In this sample Rolling.3dm (44.7 KB) the basic rotation of the wheels is installed by Rotate keyframes at 0 and 100.

The angle of the rotation in keyframe 100 (1245.755) is 360 * length of path / circumference of wheel . The formula in the Expression is a humble attempt to calculate the delay caused by the turning of the wheels’ axis.
In order to get both data (Rotate and Expression) added you have to set the Usage to Added. Combined will make some kind of average based upon the balance of the weight factor.

Rolling2.3dm (933.6 KB) shows an alternative way to accomplish the basic rotation of a rolling wheel based upon the TravelDistance parameter of the simple constraint: 360*#Object 0.TravelDistance#/25.133 (25.133=circumference of the wheel). The advantage of this method is that the motion doesn’t has to be linear but can be made variable hence introducing slowing down and speeding up.

Obviously you can extend this formula by some kind of formula for compensating the vehicle’s turning.

Bug 2 : In order to use the Position parameters of an object you have to unmark “3D tweening” in the object’s Properties hence separating X, Y and Z data.

Ah Luc, you answered just before I intended to post another problem. I will try out your suggestions, but the thing I was perplexed over was the following:

I had just discovered the need to have an Action to “drive” other Expressions, but then I discovered that some Expressions work while other doesn’t. So I had made an arbitrary circle (“FakeCircle”) to get some basic rotation, but adding or subtracting from #FakeCircle.RotationZ# doesn’t work, while multiplication and division works… have you seen the same strange effect?

I’ll be back after testing your suggestion (which BTW seems to include only multiplication and division… (but what if I want to subtract and add rotation velocity to this value… as described in the previous sentence?).

// Rolf

Arbitrary formula:
(#FakeCircle.RotateZ# * 0.99999) * 1 : Works
(#FakeCircle.RotateZ# * 0.99999) - 1 : Doesn’t work

I get also another problem,

The following formula constantly correctly produces a positive or negative value, depending on which way the vehicle turns (right or left) :

  • ... ((#front_connector.WorldAngleZ# - #rear_connector.WorldAngleZ#) / 2)

But when I use sin or cos function, then the sign flips arbitrary from tick to tick :

  • sin((#front_connector.WorldAngleZ# - #rear_connector.WorldAngleZ#) / 2)

This of course make the wheels spin like crazy back and fourth.

Is this a Bug?

// Rolf

On my system I can add and subtract to my heart’s content.
Could you please test this sample model? RotateZ.3dm (33.9 KB)
Can you specify: “doesn’t work”?[quote=“RIL, post:7, topic:43917”]
the sign flips arbitrary
[/quote]

Unfortunately the Help file or the Bongo pages do not mention that the argument of trigonometric functions is in radians rather than in degrees, probably the reason for your crazy spinning wheels.
I personally regret this because it implies * Pi /180 on any ‘read’ value (WorldAngle, ObjectAngle or Rotate).

Yes, your model works. With “work” i meant, the Result value is updated as the keyframes are advanced.

Hm. And now when I tried again the model that failed on me, suddenly it works… strange. Unfortunately I can’t say what changed since it failed.

Ah, yes, that makes sense. Thanks, I’m sure that will fix the problem!

// Rolf

A tip: you can use the constant Pi in Expressions

1 Like