Hi all,

I am trying to create a Python script to use for identifying if I have a rectangular shape or an irregular shape: I am trying to do this by checking that 2 pairs of the sides have the same lengths.

My logic would be: if more than 2 inputs are identical, then the form is regular, otherwise the form is irregular.

I am not so experienced with Python beyond using the elseif/if functions, so I wanted to ask if this is actually feasible.

Thanks in advance!

It’s all completely feasible if you get the coordinates of the points.

However FYI, not only will a Rhombus and a Parallelogram will also pass your test, but as any four points in Rhino3D can be 3D, they could even form a regular Tetrahedron.

Thanks for your insight James.

At the moment I am working on a particular project where I wouldn’t have this problem. Could you please elaborate on how I would use the coordinates?

Thanks in advance!

You can manually take the L^2 Norm (like Pythagoras) of each edge vector. To test if it’s a rectangle, you can take their dot product too to make sure adjacent vectors are perpendicular.

Or if you just want lengths, you can use .GetLength or rhinoscriptsyntax.VectorLength.

https://developer.rhino3d.com/api/RhinoScriptSyntax/#pointvector-VectorLength

1 Like

Thanks for you response James, it good to see this from another perspective.

1 Like