Author Topic: Hyperbolic Tessellation using C# .NET  (Read 16473 times)

0 Members and 1 Guest are viewing this topic.

vegbruiser

  • Guest
Hyperbolic Tessellation using C# .NET
« on: January 13, 2012, 07:20:53 AM »
Hi folks,

I'm currently experiencing a dramatic fall-off of workload (through no fault of my own) and have been attempting to get to grips with all-things 3D Printing-related.

One area I'm particularly keen on (because it could save users of these apparatus money in the long-run) is the use of hyperbolic tessellation to create variable-density fill within objects that are due to be 3D Printed using a machine like a Makerbot or UP! 3D Printer.

I've been researching the different methods that might be used to create the tessellation needed to (for instance) create an AutoCAD drawing that encloses a shape similar to those seen on the wikipedia page I linked to above.

I've had  a search around the wider web and this site and (thus far) I can't find any examples of people having does this using .NET.

There are however similar-looking approaches done using AutoLISP:

conic sections in plan view

-={ Challenge }=- 3-Point Circle Tangent to Two Circles, with given Point.

Best way to plot Hyperbolic Cosine curve

Turtle fractals in AutoCAD using .NET - Part 2

The problem I have is I don't fully understand what each of the best-looking AutoLISP solutions are actually doing and/or how to convert them to work with C# .NET.

I also wanted to make use of Kean's Turtle Fractal code, but am unsure of how best to modify it.

Does anyone have any pointers/samples/examples they would mind sharing to get me started (above/beyond those I've posted above)?

(I have almost completed the conversion of the code provided by Swift here: "Best way to plot Hyperbolic Cosine curve" to C# .NET but all that's going to get me is one curve!)

Thanks,

Alex.

PS. all this goes hand-in-hand with a forum post over at reprap.org and a subsequent blog post by Gary Hodgson here.

EDIT 1: Missing url at the end.

Gasty

  • Newt
  • Posts: 90
Re: Hyperbolic Tessellation using C# .NET
« Reply #1 on: January 13, 2012, 10:55:42 AM »
Hi,

Do you have an algorithm to do that tessellation?, if so, post it (in pseudo code)  along with parameter list, border conditions and every thing else needed, and may be some one here can help you with the code.

Gaston Nunez

vegbruiser

  • Guest
Re: Hyperbolic Tessellation using C# .NET
« Reply #2 on: January 13, 2012, 11:14:05 AM »
Hi Gasty,

At the moment, I don't have anything that can even approach the level of complexity required.

I'm still getting my head around the best way of achieving what I want.

In the meantime, I have managed to complete my translation of the Hyperbolic Cosine Curve Method I linked to above:

Code: [Select]
        /// <summary>
        /// From here: http://bit.ly/yazZHH
        /// </summary>
        [CommandMethod("HCC")]
        static public void hyperbolicCosineCurve()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            Polyline2d pl;
            Point3dCollection pts = new Point3dCollection();
            double lowbound;
            double upbound;
            double step;
            double e;
            double pi;
            double i;
            int k;
            double[] coords = null;
            int start;
            int finish;

            start =0;
            e= Math.E;
            pi= Math.PI;

            lowbound = 0;
            upbound = pi * 2;
            step = 0.01;

            finish = Convert.ToInt32((upbound - lowbound) / step);
            coords = new double[finish * 2 +1];
            i = 0;
            k = 0;
            PromptPointOptions insPoint = new PromptPointOptions("\nPlace the Curve");
            insPoint.AllowNone = false;
            PromptPointResult res = ed.GetPoint(insPoint);
            if (res.Status != PromptStatus.OK)
            {
                return;
            }
            Point3d curveStart = res.Value;
            for (i = lowbound; i < upbound - step; i+= step)
{
                coords[k] = i;
                k = k + 1;
                coords[k] = 0.5 * (Math.Pow(Math.E, i) + Math.Pow(Math.E, -i));
                //'coords(k) = Sin(i)
                k = k + 1;
}
            //pts.Add(curveStart); //no need to add our pick point as a point, since the curve starts at a location near to this anyway.
            for (i = 0; i < k; i+= 2)
            {
                int j = Convert.ToInt32(i);
                pts.Add(new Point3d(coords[j] + curveStart.X, coords[j + 1] + curveStart.Y, 0));
            }
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                Polyline3d rectang = new Polyline3d(Poly3dType.SimplePoly,pts, true);
                BlockTableRecord btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                btr.AppendEntity(rectang);
                tr.AddNewlyCreatedDBObject(rectang, true);
                tr.Commit();
            }
        }

This creates a Hyperbolic Cosine Curve and adds it to modelspace. I guess I could bolt this method onto the Fractal Tree code that Kean wrote here. (but modify the HCC method to use start and end points generated by the TurtleEngine)

I'll have a think about the points you raised over the weekend and update again on Monday.

Thanks.

vegbruiser

  • Guest
Re: Hyperbolic Tessellation using C# .NET
« Reply #3 on: January 13, 2012, 11:56:08 AM »
FYI: this is the kind of effect I'm looking to create:

Gasty

  • Newt
  • Posts: 90
Re: Hyperbolic Tessellation using C# .NET
« Reply #4 on: January 13, 2012, 03:15:24 PM »
Hi Alex:

I found this paper:http://www.d.umn.edu/~ddunham/dundimacs.pdf , it depict an algorithm to tessellate spaces.

Gaston Nunez

Kean

  • Newt
  • Posts: 48
Re: Hyperbolic Tessellation using C# .NET
« Reply #5 on: January 16, 2012, 05:03:26 AM »
Hi Alex,

Over the weekend I managed to get the code from this post working inside AutoCAD:

http://liris.cnrs.fr/david.coeurjolly/doku/code/poincare

The problem I'm facing is that this creates hyperbolic triangles, but nothing more complex. I've contacted the author, to see what advice he has for me. We'll see if it goes anywhere.

(You can expect a blog post on this at the end of the week, whether I end up being successful getting hyperbolic tilings inside AutoCAD, or not.)

Kean

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8639
  • AKA Daniel
Re: Hyperbolic Tessellation using C# .NET
« Reply #6 on: January 16, 2012, 06:33:53 AM »
Ahah! we found something Kean cannot resist  :laugh:

vegbruiser

  • Guest
Re: Hyperbolic Tessellation using C# .NET
« Reply #7 on: January 16, 2012, 10:54:35 AM »
Hi Alex:

I found this paper:http://www.d.umn.edu/~ddunham/dundimacs.pdf , it depict an algorithm to tessellate spaces.

Gaston Nunez
Thanks for the link Gasty, I just realised why I recognized that .pdf by Douglas Dunham; I downloaded a less-technical version of that very document last week. :-)

Kean

  • Newt
  • Posts: 48
Re: Hyperbolic Tessellation using C# .NET
« Reply #8 on: January 16, 2012, 11:03:12 AM »
Just to keep you all informed... I seem to be making some progress (ahem). :roll:

Kean

vegbruiser

  • Guest
Re: Hyperbolic Tessellation using C# .NET
« Reply #9 on: January 16, 2012, 11:08:14 AM »
Just to keep you all informed... I seem to be making some progress (ahem). :roll:

Kean
Hehe, looks like it's heading in the right direction Kean. I hope this isn't keeping you too busy..?

Kean

  • Newt
  • Posts: 48
Re: Hyperbolic Tessellation using C# .NET
« Reply #10 on: January 16, 2012, 11:09:29 AM »
It's too much fun!  :lol:

Actually things are looking better than I thought, when I reduce the number of "layers"...

Kean

vegbruiser

  • Guest
Re: Hyperbolic Tessellation using C# .NET
« Reply #11 on: January 16, 2012, 11:59:33 AM »
That does look much better. :-)

Is the attached file I found any help?

Kean

  • Newt
  • Posts: 48
Re: Hyperbolic Tessellation using C# .NET
« Reply #12 on: January 16, 2012, 03:15:22 PM »
I found the problem - this is looking much better, now. :-)

I'll start posting code later in the week...

Kean

vegbruiser

  • Guest
Re: Hyperbolic Tessellation using C# .NET
« Reply #13 on: January 16, 2012, 05:02:12 PM »
Hi Kean, that's excellent work. :D

Kean

  • Newt
  • Posts: 48
Re: Hyperbolic Tessellation using C# .NET
« Reply #14 on: January 17, 2012, 10:54:14 AM »
Thanks! :-)

Just one last teaser image before I get on and start getting everything together for posting...

Kean

(It'll go out over a couple of posts - Friday and Monday, I expect - so I'll send you something by email, in the meantime, Alex.)