What is the right format for this expression?

Hi, I’m trying to clean up my script using an expression. But it seems the format is not right.

Sqrt(1−u²(1−(n⋅i)²))n+u(i−(n⋅i)n)

Here the formula i want to implement
Screenshot 2022-10-31 103849

I think you can’t just omit the multiplication signs.

Sorry, I cannot post an asterix sign here. the Error I get is: Syntax error: Invalid expression. (1519)

Here the * are missing!

Use the </> code tag? Please show us what worked? This doesn’t:

Sqrt(1−u²*[1−(n•i)²])*n+u*[i−(n•i)*n]

“n1” is a new variable, not the same thing as “n•i”. (Dot product)
Neither is “n*i”. Still a mystery to me?

Screenshot 2022-10-31 124518
This worked for me

Using </> code syntax:

(Sqrt(1-u²*(1-(n*i)²)))*(n+(u*(i-(n*i)*n)))

Yes, it works for the expression but is it the same as the formula you want to implement?

It doesn’t look the same to me. And what about the unitize ([]) and dot product (•) elements?

I started to implement the formula (as I understand it) with components and quickly encountered an error at 1-(n•i)² (OOPS! I used XProd instead of DProd - but then unitize fails?)


expression_2022Oct31b.gh (10.0 KB)

Guess your right, I’ll also try do deconstruct it will individual components and see if it’s a match.

I want to replicate Snell’s Law formula and I with this expression I at least get the same output when I compare it to the Refract component in Mosquito plugin.