My week-end challenge and DC problems
-
Perhaps something like this for
AngleA
and also forAngleB
?
=IF(Course=0, 0, 29.0735587-ACOS((La*La+Course*Course-Lb*Lb)/(2*La*Course)))
To stop the divide by zero error ?? -
... don't work
I tried in a simple model with a
X=if(Value=0,0,100/Value) onClick : ANIMATESLOW(Value,100,0)
The component must move from X=1 to X=infinite, but must finish at X=0
But when the value is 0 there is an error and the component stop where is it.
I think if there is an error, SU don't interpret nothing
-
Did you try the whole thing for AngleA and AngleB as I set it out ?
Perhaps putting ( ) around the second action... -
Not needed to touch the
AngleA
andAngleB
, the problem is not there because theCourse
never be 0 (Course
is the total length of each the hydraulic cylinder, not yet draw, and it never be equal to zero )
The problem is in theVerin X
andZ
calculated with the formulas
X = L*(sin((copy+.5)*A)-sin(A/2))/(2*sin(A/2)) Z = L*(cos(A/2)-cos((copy+.5)*A))/(2*sin(A/2))
TheL
is the length of a pieces of the bridge floor andA
is the angle between two pieces, so it will be equal to zero when the bridge is in the final position.
These formulas are equivalent to
X = L*(cos(A)+cos(2*A)+cos(3*A)+...+cos(n*A)) Z = L*(sin(A)+sin(2*A)+sin(3*A)+...+sin(n*A))
If there is an other equivalent without a division bysin(a)
it will be nice... -
How about
X = IF(sin(A/2)=0, 0, L*(sin((copy+.5)*A)-sin(A/2))/(2*sin(A/2)))
??? -
@tig said:
How about
X = IF(sin(A/2)=0, 0, L*(sin((copy+.5)*A)-sin(A/2))/(2*sin(A/2)))
???No Always saying there is divided by zero and don't return the zero when A=0 (and so sin(A/2)=0)
-
Finished
I haven't solved the divide by zero problem... but it works, and slowly -
You deserve a medal for that! With a day to spare what will you do with your time?
-
Yes, well done!
An excellent 'complex DC'.I still can't see why the IF() doesn't work to trap zero-divide issue ?
perhaps extra ( ) ???
X = IF(**(**sin(A/2)=0**)**, 0, **(**L*(sin((copy+.5)*A)-sin(A/2))/(2*sin(A/2))**)**)
-
@tig said:
I still can't see why the IF() doesn't work to trap zero-divide issue ?
perhaps extra ( ) ???
X = IF(**(**sin(A/2)=0**)**, 0, **(**L*(sin((copy+.5)*A)-sin(A/2))/(2*sin(A/2))**)**)
Testing this kind of solution, I think SU want to evaluate any member of the IF before solving it, and if is an error it returns nothing but an error, even the error is in a non needed part of the function
But...
Reading your post I had a machiavellian idea : two
IF
in the function, one like you propose, one under the divide
X = IF(sin(A/2)=0, 0, L*(sin((copy+.5)*A)-sin(A/2))/**IF(2*sin(A/2)=0, 1, 2*sin(A/2)**)
The value for the true secondIF
can be anything but zero, just to avoid the divide by zero error, and the final result will be zero due to the firstIF
.It works on the Divide_Zero.skp I sent before when Value = 0
X = if(Value=0,0,100/if(Value=0, 1, Value))
I will test it soon on the bridge model. It's already slow, and with 2 IF more in each part of the bridge, it can't be faster. But in real, it's slow
-
@unknownuser said:
You deserve a medal for that! With a day to spare what will you do with your time?
Looking for an other challenge !
-
OR perhaps go back to where 'A' is set and use something like
=IF(A=0, 0.0001, A)
then A is never quite 0 ? -
@tig said:
OR perhaps go back to where 'A' is set and use something like
=IF(A=0, 0.0001, A)
then A is never quite 0 ?Good idea too !!
Faster, but the bridge never be horizontal. OK, 0.0001 is quite horizontal... but not . I'm a man thinking Zero is not quite Zero
So two solutions : one simple and faster but cant realy accept all angles, the other more mathematic but slow and made long sentences.Remember me the time I worked as multimedia designer. Me and a friend worked on Flash and for the same job, I made 1 frame and 200 lines of actionscript, and my friend made 1 line of actionscript and 200 frames
-
You'll also probably find that when it looks flat, in reality the bridge is slightly 'arched' [in a shallow 'hump'], because it will deflect under its own weight and the people standing on it, the engineer would want it to 'settle-down' to be no more than 'flat', in a 'worst case'.
So this is then even more complicated, because it means at some point the parts will go from a positive 'arch' to a negative 'curl', passing through 'zero' just after it has started to 'rollup'...
-
@tig said:
You'll also probably find that when it looks flat, in reality the bridge is slightly 'arched' [in a shallow 'hump'], because it will deflect under its own weight and the people standing on it, the engineer would want it to 'settle-down' to be no more than 'flat', in a 'worst case'.
So this is then even more complicated, because it means at some point the parts will go from a positive 'arch' to a negative 'curl', passing through 'zero' just after it has started to 'rollup'...
Yes, I noticed the arc, but not at the end.
If you set the Course value to can se the end of the bridge dive into the pier
In the final position, Course = 109 (or 109.2 to avoid the divide by zero ) all is quite horizontal in my model.
But in the model quite all is parametric. So if I want to have an arc at the end, just change the Lb value for little greater. This dimension is the size of the arms, that don't change the mesh size but just de calculation, so the axes aren't on the right place, but at the end the bridge is arched. -
Here is a little guide to understand the variables :
All the variables don't change the shape of the bridge, only the calculation.
Only Course, La and Lb are variables ; Angles are calculated with them. -
i had a similar problem before..
the way i ended up dealing with it was by adding another attribute.. it wasn't elegant at the time and it still isn't ..your double if statement seems better but i'll post the method anyway.. (might get the discussion going again to find a better solution than either of these)
for your Divide_Zero.skp, it would look like:
Position
X =if(trap=.12345,0,100/trap)Custom
trap =if(value=0,.12345,value)
value =(user input)you'd just have to make sure the trap value (.12345 in this example) is a number that should never come up as input..
not sure but doing it like this might speed things up if you have to enter the double IF statement for all parts of the bridge.. this will result in one IF statement in each part of the bridge plus a single extra IF
-
@unknownuser said:
Here is a little guide to understand the variables :
[attachment=0:20dsmooa]<!-- ia0 -->02_1.jpg<!-- ia0 -->[/attachment:20dsmooa]
All the variables don't change the shape of the bridge, only the calculation.
Only Course, La and Lb are variables ; Angles are calculated with them.Instead of checking sin(a) have you considered checking the angle. There are only a few cases( maybe only a=0) that would need checking constrained by your geo. Conversely can't you create a variable say z= sin(a) and do a check on that?? you could even go as far as using a taylor series exapnsion for all if SU has problem with small angles.
-
@unknownuser said:
Position
X =if(trap=.12345,0,100/trap)Custom
trap =if(value=0,.12345,value)
value =(user input)I like this solution Simple and economic.
As you say, the only inconvenient is to found an unusable value for the test. In the case of the bridge, no problem? because the angles are limited.
I will test it soon -
Three years ago, I made this model to test DC and my trigonometry knowledge. I bring out it to show my students the wonder of SU Dynamic Components.
But...After the divide by zero problem we talk in this thread, I have a new problem with SU 2015 (on Windows 7 and 8 64): it seems that there are any problems with very small numbers.
That's what happen when I roll and unroll the bridge on SU 2015 :
That's is the good position after the sams operation on SU 8 :
If I explore components, I find it :
An error is highlighted on a very little number with a negative exponent e-6. Is the result of a COS calculated in the formula.
Perhaps SU DC don't understand this way to write a number and consider it like a text... Perhaps...Some one have same issue with this model or other DC ?
Advertisement