Itoo Software Forum

Author Topic: Spacing within a railing - Looking for the correct trigonomerty expression  (Read 220 times)

Pixelab

  • Jr. Member
  • **
  • Posts: 83
  • Suave mari magno
    • pixelab.be
Here is a glass railing from above, I'm trying to make a formula that automatically makes the space between the glass. Circled in red are the corner not working properly (180°+ angles)

Looks like RC do the job correctly for sub 180 angles.

I've tried many solution but can't get the right trigo formula. Would be nice to be able to paramter it with min/max spacing values.

FWIW I've attached the file I'm working on but the expression is a mess. RC version is 3.1.8b, Max 2016


Rokas

  • iToo Software
  • Hero Member
  • *****
  • Posts: 2669
    • iToo
Hi

How should it look correctly when angle>= 180 ?
Rokas
iToo Software

Pixelab

  • Jr. Member
  • **
  • Posts: 83
  • Suave mari magno
    • pixelab.be
Hi

How should it look correctly when angle>= 180 ?

With a space enough to avoid collision between the elements (see the overlap circled in red)

I guess the formula will give infinite for 360°

Dragan

  • Hero Member
  • *****
  • Posts: 561
Hi
Check this generator. I added a few more parameters so now you can have different spacers for Evenly and Corners 1 & 2 which are controled by the Angel Threshold parameter.
Please let me know if this is works for you.
And as Rokas ask, we need to know how spacing will change when angle is greater than 180.

Best Regards
Dragan
« Last Edit: October 16, 2020, 11:03:20 PM by Dragan »

Dragan

  • Hero Member
  • *****
  • Posts: 561
I just saw you are using RC 3...
Please go to RC4, you will not regret it ;)
I`m not sure this will work on RC3 but you can try.


Pixelab

  • Jr. Member
  • **
  • Posts: 83
  • Suave mari magno
    • pixelab.be
Thanks for the help, but what I'm looking for is a dynamic formula that spaces the glass enough to avoid collisions.

I know it involves trigonometry but so far my attempts have been unsuccessful.

This was for example a formula to scale an object based on the Vertex Angle

Code: [Select]
return 100/cos((pi-XVertexAngle)/2);
« Last Edit: October 19, 2020, 04:06:58 PM by Pixelab »

Pixelab

  • Jr. Member
  • **
  • Posts: 83
  • Suave mari magno
    • pixelab.be
Ok, I finally found the formula I was looking for.

I've attached the max file for those who are intrested

Code: [Select]
return (tan((pi-XVertexAngle)/2)*Input1)+Input2;


Input1 is the space you want at 270°
Input2 is the minimum space used for sub 180° angles


Dragan

  • Hero Member
  • *****
  • Posts: 561
Please, try this one.
The distance you are calculating depends on Y size and XvertexAngle. I set the GlassMid segment to be Master for the Y size.
I had to change Y alignment to Center but you can still adjust it with the Y offset parameter.
The Spacer is both for Evenly and Corner but I can make them separate if you need.


« Last Edit: October 20, 2020, 10:28:10 AM by Dragan »

Pixelab

  • Jr. Member
  • **
  • Posts: 83
  • Suave mari magno
    • pixelab.be
Please, try this one.

Thanks, it's indeed much more elegant ! I knew that the second variable could be deducted from Y size but simplifying the overall style is nice

Glad the formula is still there and that I didn't scratch my head for nothing ;)