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

#### Pixelab

• Jr. Member
• Posts: 83
• Suave mari magno
##### Spacing within a railing - Looking for the correct trigonomerty expression
« on: October 16, 2020, 05:08:05 PM »
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: 2583
##### Re: Spacing within a railing - Looking for the correct trigonomerty expression
« Reply #1 on: October 16, 2020, 05:18:02 PM »
Hi

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

#### Pixelab

• Jr. Member
• Posts: 83
• Suave mari magno
##### Re: Spacing within a railing - Looking for the correct trigonomerty expression
« Reply #2 on: October 16, 2020, 05:34:47 PM »
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: 504
##### Re: Spacing within a railing - Looking for the correct trigonomerty expression
« Reply #3 on: October 16, 2020, 08:12:21 PM »
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: 504
##### Re: Spacing within a railing - Looking for the correct trigonomerty expression
« Reply #4 on: October 16, 2020, 11:05:38 PM »
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
##### Re: Spacing within a railing - Looking for the correct trigonomerty expression
« Reply #5 on: October 19, 2020, 03:00:34 PM »
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
##### Re: Spacing within a railing - Looking for the correct trigonomerty expression
« Reply #6 on: October 19, 2020, 05:56:35 PM »
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: 504
##### Re: Spacing within a railing - Looking for the correct trigonomerty expression
« Reply #7 on: October 20, 2020, 08:45:52 AM »
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
##### Re: Spacing within a railing - Looking for the correct trigonomerty expression
« Reply #8 on: October 20, 2020, 02:02:58 PM »