[Plugin] Superellipse 1.2

[Plugin] Superellipse 1.2

Postby Regular Polygon » Thu Jun 17, 2010 11:32 pm

Hi everyone,

First of all, let me say that this forum has been a helpful resource. I have often found answers for my own plugin development problems already addressed here. It is also interesting to follow the continuing evolution of new SketchUp plugins posted here.

I wrote a few plugins over the years that are just languishing on my hard drive. My plan is to write them up on a blog, and then announce them on your forum.

This first plugin draws a superellipse. It is pretty simple, but as far as I know it hasn't been done before. A superellipse is a shape that is in between an ellipse and a rectangle, (or a circle and a square, if both axes are equal). For example, here is a cube with superellipse shaped windows.

superellipse 1.PNG


A parameter, n, controls the degree of "squareness." As n gets larger, the curve looks more and more like a rectangle with rounded corners.

superellipse 2.PNG


# CHANGELOG

# 1.1 - June 23, 2010
# * Implements new scale to describe squareness.

# 1.2 - July 7, 2010
# * Remembers last dialog box values between sessions.


The Superellipse plugin is at: regularpolygon.org/plugins/superellipse.php.

Thanks.
0
Last edited by Regular Polygon on Thu Dec 08, 2011 7:21 am, edited 2 times in total.

Regular Polygon 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse

Postby thomthom » Thu Jun 17, 2010 11:56 pm

:thumb:

Welcome to SCF! :D Excellent first post.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse

Postby Chris Fullmer » Fri Jun 18, 2010 12:30 am

Wow, yeah thats great! Welcome, thanks for the plugin,

Chris
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: [Plugin] Superellipse

Postby pilou » Fri Jun 18, 2010 12:57 am

Cool! :thumb:

Next Will be Super Cycloïd? :enlight:
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [Plugin] Superellipse

Postby Regular Polygon » Fri Jun 18, 2010 4:08 am

Pilou wrote:Next Will be Super Cycloïd? :enlight:


Yeah, that sounds like a plugin I would work on. They tend to have that sort of mathematical flavor.
0

Regular Polygon 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse

Postby SU Reviewer » Fri Jun 18, 2010 10:01 pm

Welcome! Another great and simple plugin.

It works really well, though I have a note on the Exponent value. There is no known scale for the exponent input that I could tell. As of now its pretty much a shot in the dark as to how square the superellipse will come out. Perhaps having a scale of 1-100 (100 being a perfect square) the plugin would be more manageable?

Good job! :thumb:
0
Living Einstein's dream through SketchUp.
"Imagination is a preview of life's coming attractions" - Albert Einstein

Joe Simhon ~ SketchUp Plugin Reviews

SU Reviewer 
 

Re: [Plugin] Superellipse

Postby remus » Fri Jun 18, 2010 10:38 pm

Why replace one arbitrary scale with another? they'll both serve the same purpose, and as long as the user understands 'big n = more square' you cant go too far wrong.
0

remus 
 

Re: [Plugin] Superellipse

Postby Regular Polygon » Sat Jun 19, 2010 1:10 am

SU Reviewer wrote:As of now its pretty much a shot in the dark as to how square the superellipse will come out. Perhaps having a scale of 1-100 (100 being a perfect square) the plugin would be more manageable?

Otherwise great plugin!


Thanks for your review!

I can see your point. It is not real intuitive to me either how square the superellipse will be for a given exponent value.

We could replace the exponent with a scale that runs from 1-100. If 1 represents a completely round shape, then we would associate it with an ellipse. At the other end, 100 represents a completely square shape, so we associate it with a rectangle. But it is not so obvious to me what the numbers in the middle represent. Which superellispe should correspond to a scale factor of say 50?
0

Regular Polygon 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse

Postby boofredlay » Sat Jun 19, 2010 2:39 am

Oh man, I could have used this about 4 days ago. This is one of those quick scripts I imagine using quite often.

Thank you very much. :!:
0
User avatar
boofredlay 
Global Moderator
 

Re: [Plugin] Superellipse

Postby Ben Ritter » Sat Jun 19, 2010 3:05 am

Thank you Regular Polygon.
0

Ben Ritter 
 

Re: [Plugin] Superellipse

Postby thomthom » Sat Jun 19, 2010 9:55 am

Is "Regular Polygon" a reference to Flat Land?
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse

Postby Dave R » Sat Jun 19, 2010 11:15 am

Thank you for this plugin. It is very nice.

I think the exponent makes sense. After all, it's a logical input considering the formula you're solving. Length and width are a and b so why not define n? I would prefer that to some arbitrary 1-100 scale.

0
%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] Superellipse

Postby brookefox » Sat Jun 19, 2010 5:46 pm

Dave R wrote:I think the exponent makes sense. After all, it's a logical input considering the formula you're solving. Length and width are a and b so why not define n? I would prefer that to some arbitrary 1-100 scale.



Silly me thought you figured that formula out for yourself, Dave.

Since I have no sense at this point where the exponent variable will take me, though I guess that comes with practice, the 1-100 option has some appeal. I should hold my tongue until I practice, but I won't.

Thanks for the contribution, rp, and for adding the loci to the ellipse.
0
~ Brooke
User avatar
brookefox 
 

Re: [Plugin] Superellipse

Postby remus » Sat Jun 19, 2010 7:08 pm

A quick question about using values of n<1 if i may: how do you handle it, because surely you'll end up trying to take roots of negative numbers which'll give you imaginary numbers, unless you just take the imaginary part and use that?
0

remus 
 

Re: [Plugin] Superellipse

Postby Regular Polygon » Sat Jun 19, 2010 9:54 pm

thomthom wrote:Is "Regular Polygon" a reference to Flat Land?


No, not really.

"Regular Polygon" is kind of a play on words. It could mean an ordinary, everyday, run-of-the-mill polygon (i.e. the basic element of 3D graphics). But, in the mathematical sense, it means a symmetrical polygon whose angles and edges are all equal.
0
Last edited by Regular Polygon on Sun Jun 20, 2010 8:01 am, edited 2 times in total.

Regular Polygon 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse

Postby Regular Polygon » Sat Jun 19, 2010 10:56 pm

remus wrote:A quick question about using values of n<1 if i may: how do you handle it, because surely you'll end up trying to take roots of negative numbers.


Here is the code that computes the coordinates.

Code: Select all
def sgn(num)
  return  0  if num.zero?
  return +1  if ( num > 0 )
  return -1
end


# Compute the points for the vertices of the superellipse
def points
  e = 2.0 / @exp
  pts = []
  delta = 2 * Math::PI / @edges
  for i in 0...@edges do
    phi = i * delta
    x = @a * sgn(Math.cos(phi)) * Math.cos(phi).abs**e
    y = @b * sgn(Math.sin(phi)) * Math.sin(phi).abs**e
    pts.push([x, y, 0])
  end
  pts.push(pts[0])  # close the loop
  pts
end


The only trick is to take the absolute value before you raise a number to a fractional power. After that, multiply it by +1 or -1, depending on the sign the original number had.
0

Regular Polygon 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse

Postby remus » Sat Jun 19, 2010 11:08 pm

That makes sense, cheers.
0

remus 
 

Re: [Plugin] Superellipse

Postby Regular Polygon » Wed Jun 23, 2010 9:52 pm

I have just released a new version 1.1 of the Superellipse plugin. This version allows you to specify the "squareness" of a superellipse using a scale. The exact association between the scale and the squareness is spelled out in gory detail in the post on my blog. But a picture is probably worth a 1000 words.

scale 8.PNG


Basically, 0 corresponds to an ellipse, 100 corresponds to a rectangle, and a scale factor of 50 corresponds to a superellipse that stretches 50% of the way in between. I think this makes assigning a squareness value fairly intuitive.

You can run both versions (1.0 and 1.1) at the same time to compare them. To download the plugin, or read more about it, please visit my blog at http://regularpolygon.blogspot.com/

Thanks.
0

Regular Polygon 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse

Postby olishea » Thu Jun 24, 2010 11:06 am

thanks for sharing :thumb:
0
oli
User avatar
olishea 
Premium Member
Premium Member
 

Re: [Plugin] Superellipse

Postby simon le bon » Thu Jun 24, 2010 11:20 am

thanks for sharing :thumb:
we will see, but it would prove itself often useful in time
++simon
0
User avatar
simon le bon 
 

Re: [Plugin] Superellipse

Postby Regular Polygon » Fri Jun 25, 2010 2:12 am

Hey, thanks everyone for the big welcome, and your show of support, for this first -- albeit simple -- plugin.
0

Regular Polygon 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse

Postby pyroluna » Fri Jun 25, 2010 10:39 am

Really nice... but it reminds me... I used to use POV-Ray some years ago, in which it was possible to create a 3d-superellipsoid.
Could you make that??? :D would be so awesome, I used to use it a lot!
Perhaps in SU it would need a variable for level of detail, though...
POV-Ray help files wrote:The superellipsoid object creates a shape known as a superquadric ellipsoid object. It is an extension of the quadric ellipsoid. It can be used to create boxes and cylinders with round edges and other interesting shapes. Mathematically it is given by the equation:
formula.jpg

The values of e and n, called the east-west and north-south exponent, determine the shape of the superquadric ellipsoid. Both have to be greater than zero. The sphere is given by e = 1 and n = 1.

The syntax of the superquadric ellipsoid is:

SUPERELLIPSOID:
superellipsoid
{
<Value_E, Value_N>
[OBJECT_MODIFIERS...]
}

The 2-D vector specifies the e and n values in the equation above. The object sits at the origin and occupies a space about the size of a box{<-1,-1,-1>,<1,1,1>}.

Two useful objects are the rounded box and the rounded cylinder. These are declared in the following way.

#declare Rounded_Box = superellipsoid { <Round, Round> }
#declare Rounded_Cylinder = superellipsoid { <1, Round> }

The roundedness value Round determines the roundedness of the edges and has to be greater than zero and smaller than one. The smaller you choose the values, the smaller and sharper the edges will get.

Very small values of e and n might cause problems with the root solver (the Sturmian root solver cannot be used).
0
User avatar
pyroluna 
 

Re: [Plugin] Superellipse

Postby Regular Polygon » Fri Jun 25, 2010 9:28 pm

Pyroluna wrote:Really nice... but it reminds me... I used to use POV-Ray some years ago, in which it was possible to create a 3d-superellipsoid.
Could you make that??? :D would be so awesome, I used to use it a lot!
Perhaps in SU it would need a variable for level of detail, though...


Thanks, glad you like it. Funny you should ask because, in fact, I do have a superellipsoid plugin. It lets the user enter the number of lines of latitude and longitude to control the level of detail.

It was interesting to see how POV-Ray is dealing with the exponents in the formula. They let the user specify a Roundedness value, whereas I came up with a Squareness value. I'll have to try out both approaches to see which I like better.

Anyway, I should get the superellipsoid plugin polished up, and posted on my blog, sometime next week. Stay tuned!
0

Regular Polygon 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse

Postby SU Reviewer » Wed Jun 30, 2010 10:08 pm

Looking good! Definitely works better, will update the review. :thumb:
0
Living Einstein's dream through SketchUp.
"Imagination is a preview of life's coming attractions" - Albert Einstein

Joe Simhon ~ SketchUp Plugin Reviews

SU Reviewer 
 

Re: [Plugin] Superellipse

Postby Regular Polygon » Fri Jul 02, 2010 12:05 am

SU Reviewer wrote:Looking good! Definitely works better, will update the review. :thumb:


That is +1 vote for the new squareness scale in version 1.1. I think it improved the plugin, thanks for the suggestion.
0

Regular Polygon 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Superellipse 1.2

Postby Regular Polygon » Wed Jul 07, 2010 9:01 pm

Update to version 1.2

Previous versions started off each session with arbitrary default values in the dialog box for the Superellipse parameters. This version remembers your last dialog box values between sessions.
0

Regular Polygon 
PluginStore Author
PluginStore Author
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: zul6041 and 22 guests

Visit our sponsors: