Thursday, December 20, 2018

Some 3D folding

Over the past couple days (finals week lol) I found myself extremely motivated to make things, particularly in 3D. So I started trying to convert parts of my first big Mathematica/Wolfram Language project into 3D.

Most of the changes are cosmetic. I quickly familiarized myself with the rotation transform functions and got to work. This time around I was too unfamiliar/intimidated with the huge matrices so I just shelved it for at least a month or two. But it did inspire to start looking at some Linear Algebra material so hopefully a more direct implementation of rotation matrices can come soon?

Anyways to familiarize myself with the 3D graphics tools I glanced through the documentation and found some useful code to pick up.
First off was a quick test with creating polygons in 3space.
Then I moved on to rotating around an arbitrary vector v (In this case <1,0,0>, the x axis)
An hour or so of messing around, and I finally got the hang of the 3D folding:
Now, when I turned to revising my original code for 3D I actually noticed several things:
Firstly,  my original code was super messy and disorganized and poorly documented (oops)
I was trying to bring over some of my old functions to 3D but I was having trouble figuring out what functions did what exactly. I think a good Saturday afternoon exercise would be to cleanly rewrite the entire original program from scratch.

I was writing most of this during my TA period in school (finals week doesn't really leave much help/work for us to do around here :o) so I didn't really feel like updating most of the code or fixing it. I really only changed two functions by adding a z component and super lazily but quickly fixed the others on the fly.


















With an arbitrary point I had chosen I just directly implemented the last bit of the rotation matrices (some quick coordinate geometry resolved the question of what vector to rotate around etc.)
I was having some trouble constructing the top polygon for now as the shape folds so I've left it out for now. (My struggle is to do with the way Mathematica stores points versus ordered pairs in their 3D graphics directives)

The actual code for the finished graphic isn't published yet. I probably want to clean it up a bit but that should come soon.

Here are some pictures of my graphic so far for an arbitrary Kawasaki obeying point (the top polygon is missing, see above)






It's still missing the top polygon but you can see the resemblance to some a 2d relative of a similar figure (the opacities are not accurate in 2d, the 3d is correct, because the polygon ordering wasn't considered when the demonstration was originally made, another problem I really should resolve when I find time).


As from my Wolfram Demonstration
http://demonstrations.wolfram.com/OneVertexOrigamiFolding/

Have a nice day

No comments:

Post a Comment

Spring 2024

 I haven't updated this blog in so long. I guess I'm graduating from college soon which I have a lot of feelings about. Hopefully I ...