Page 1 of 1

### dist function - how to use it (strange errors)

Posted: Thu Feb 07, 2019 3:11 pm
Hi!

Expressions are great and thanks for this forum section but I seem to have problems using them
Very basic expressions work but I wanted to try the functions and got into problems.

I made simple test to make a box x coordinate match distance between two other boxes.
The expression code for box_dist.translate.x is:
Code: Select all
`p1=get_vec3("box_p1.translate"); p2=get_vec3("box_p2.translate"); d=sqrt((p1[0]-p2[0])^2+(p1[1]-p2[1])^2+(p1[2]-p2[2])^2); # works fine#d=dist(p1,p2); # does not work, strange errors :od `

Can you please tell me what I am doing wrong?

The errors I get are (comment out the sqrt and uncomment the dist line):
Expression bound on project://box_dist.translate[0] failed to compile:
Line 4 Col -47 - Too few args for function dist
Line 4 Col -49 - Assignment operation has bad type: lifetime_error Error

Too few args???? The manual says two vectors and those are two vectors

Thank you!

Antti

### Re: dist function - how to use it (strange errors)

Posted: Thu Feb 07, 2019 4:26 pm
Hi Antii,

The 'dist' function is a native SeExpr one, and the documentation is incorrect (see the official SeExpr documentation)
The correct signature of dist is in fact `dist(ax, ay, az, bx, by, bz)`
In your example, this expression should work:

Code: Select all
`p1 = get_vec3("box_p1.translate");p2 = get_vec3("box_p2.translate");# sidenote: the very last statement is what's used as the expression's result, so you don't need# to write 'd = dist(...)' :dist(p1[0], p1[1], p1[2], p2[0], p2[1], p2[2])`

Hope this helps !

### Re: dist function - how to use it (strange errors)

Posted: Thu Feb 07, 2019 4:38 pm
Ah ok, does that apply to other SeExpr functions as well? So we should use the official docs and not Clarisse docs?
That does not help with printf though (see my other post), the syntax is the same in both docs so please help me there

I will check that documentation, thank you!

Yes dist works now

Antti

### Re: dist function - how to use it (strange errors)

Posted: Thu Feb 07, 2019 4:38 pm
Unfortunately it seems the official SeExpr doc isn't completely accurate. As we didn't test every single function there may be many other functions that aren't documented properly. Our own documentation is based on the official one....

### Re: dist function - how to use it (strange errors)

Posted: Thu Feb 07, 2019 4:39 pm
atnreg wrote:Ah ok, does that apply to other SeExpr functions as well? So we should use the official docs and not Clarisse docs?
That does not help with printf though (see my other post), the syntax is the same in both docs so please help me there

I will check that documentation, thank you!

Antti

No the official doc is wrong, and as ours is based on it, it is wrong too...

### Re: dist function - how to use it (strange errors)

Posted: Thu Feb 07, 2019 4:43 pm
sam wrote:
atnreg wrote:Ah ok, does that apply to other SeExpr functions as well? So we should use the official docs and not Clarisse docs?
That does not help with printf though (see my other post), the syntax is the same in both docs so please help me there

I will check that documentation, thank you!

Antti

No the official doc is wrong, and as ours is based on it, it is wrong too...

Oh, hmm...then HOW we are supposed to know how to use those?
And furthermore, how do YOU know how to use them, as far as I understand you have had that feature in your internal version for a while (I remember seeing that zigma sign in some videos quite a long time ago)?

Antti

### Re: dist function - how to use it (strange errors)

Posted: Thu Feb 07, 2019 4:47 pm
atnreg wrote:Oh, hmm...then HOW we are supposed to know how to use those?

We are exactly in the same position as you are. We connected the SeExpr to Clarisse and added specific extensions: https://clarissewiki.com/4.0/clarisse-specifics.html

So for the "standard" SeExpr we have the exact same amount of resources as you have (and little bit more experience)

### Re: dist function - how to use it (strange errors)

Posted: Thu Feb 07, 2019 5:32 pm
sam wrote:
atnreg wrote:Oh, hmm...then HOW we are supposed to know how to use those?

We are exactly in the same position as you are. We connected the SeExpr to Clarisse and added specific extensions: https://clarissewiki.com/4.0/clarisse-specifics.html

So for the "standard" SeExpr we have the exact same amount of resources as you have (and little bit more experience)

Ok, then you will receive a lot of questions on how to use them (I believe not only from me), beware

Antti