Title: Circle2Square Post by: M Benesi on November 08, 2015, 09:02:19 PM k.. back to this:
Given I don't understand how your spheric works (explanation? :D ) Square part (not whole cube!) that "squares the circle" on the x axis (click to enbiggen):(https://lh3.googleusercontent.com/-v3yKU0gPhzs/Vjz6k7f-_wI/AAAAAAAADfE/kcsbb-RlIZ0/s480-Ic42/Untitled.jpg) (https://lh3.googleusercontent.com/-v3yKU0gPhzs/Vjz6k7f-_wI/AAAAAAAADfE/kcsbb-RlIZ0/s340-Ic42/Untitled.jpg) The rest can be worked out from the inverse functions page on Wikipedia, (https://en.wikipedia.org/wiki/Inverse_trigonometric_functions) or you can do it geometrically with the Pythagorean theorum... (theta= atan2(y/x) if you're doing the inverse function thing! I can explain it further later, if you want) ...... Continued...................................................>>>>>> UPDATE... a bit of math was wrong. :D fixed.. or not. UPDATE... sheesh.. I deleted the wrong thing in the last update.. anyway. If the math is STILL wrong.. you'll notice. (https://lh3.googleusercontent.com/-rBvbe6nT5cs/VkBU0IGIELI/AAAAAAAADkc/gVc0BYK8yAs/s480-Ic42/circle%252520to%252520square.jpg) You can look at the inverse functions on wikipedia, and see how I got from the above to the equations I used, or you can do it geometrically. tan theta = opposite/adjacent = z/y You can see in the drawing, that r is the length of the bottom of the right triangle that is r tan(theta) high. The smaller triangle has a height of r sin(theta). We are interested in the ratio between the 2 triangles, to either stretch from the circle to the square, or stretch from the square to the circle. The ratio of one hypotenuse to the other is the same as the ratio of one side to another, etc. so we use the ratio of tan(theta)/sin(theta)= 1/cos(theta) for our calculations, as long as it is in the correct quadrant! In the above image, if the tangent is past the corner of the square, you need to flip y and z in your calculations. It actually is a more general formula for creation of polygons from circles, the square one is just the simplest, because you don't have to do more complex rotations. For some reason, I think Knighty did something similar with his cutting formulas. To make a circle into a triangle, you need to divide it into 3 sections and do basically the same thing.... Code: //combine with tubular Title: Circle2Square Post by: DarkBeam on November 08, 2015, 11:56:33 PM Now it is very clear
Thanks Matt... And I reccomend you - always post m3f files in the same thread or I am not finding them. Please... :) keep the topics separed. Do not force me to move topics all the times. :beer: Luca Title: Circle2Square Post by: M Benesi on November 09, 2015, 12:41:08 AM Now it is very clear Thanks Matt... And I reccomend you - always post m3f files in the same thread or I am not finding them. Please... :) keep the topics separed. Do not force me to move topics all the times. :beer: Luca Apologies... again. I am quite scatterbrained at times. Title: Circle2Square Post by: mclarekin on November 09, 2015, 04:02:50 AM @M.Benesi
Thanks for the detailed explanation, it is interesting to see how you do it :) O0 Title: Circle2Square Post by: M Benesi on November 09, 2015, 07:34:44 AM Thanks. It's useful for me too.. consolidates ideas. And I'll forget, and be able to look later. :D
Title: Re: Circle2Square Post by: DarkBeam on November 09, 2015, 12:47:57 PM Splitted to be more visible :dink: :beer:
Title: Re: Circle2Square Post by: mclarekin on November 11, 2015, 08:32:10 AM I started coding but then came across this "z.yz" which seems not to work in C++. How is it defined? And what computer language are you using?
Code: Description: Title: Re: Circle2Square Post by: DarkBeam on November 11, 2015, 09:25:17 AM In other words multiply y and z by rCyz.
It is glsl :) Title: Re: Circle2Square Post by: 3dickulus on November 11, 2015, 09:55:18 AM @mclarekin you need some vector classes, your math libs should have some, search for vector.h
Fragmentarium-Source/SyntopiaCore/Math/ has vector and matrix classes, Qt provides really nice ones with lots of builtin functions. iirc there should be one out there for doing GLSL style math in C++ Title: Re: Circle2Square Post by: mclarekin on November 11, 2015, 10:26:54 AM Thanks guys ;D
@ DarkBeam, i guessed it might be that, and useful to know. GLSL looks quite similar to C++, good. :) @3dickulus. Never needed ( or seen ) this type of vector before. I rely on real programmers (Buddhi and Sebastian) to do anything more difficult than an if() statement. LOL But I am learning more and more each day, generally though fixing my mistakes. ;D BTW I now have some comprehension of the massive amount of time and thought that has gone into creating and upgrading these programs. :beer: :beer: :beer: :beer: Title: Re: Circle2Square Post by: visual.bermarte on November 11, 2015, 02:47:08 PM z.x is the first element of z vector, also written as z[0]
z.y is the second element of z vector, also written as z[1] z.z is the third element of z vector, also written as z[2] Swizzling is done using the dot operator and it is an handy way to manipulate vectors's elements, for example having vec4 z = vec4(0.0, 0.9, 0.1, 0.0); one could write vec3 j = z.xyz; and j would be equal to vec3(0.0, 0.9, 0.1); j[0] would be float(0.0) j[1] would be float(0.9) ... writing j or j.xyz wouldn't be different. Title: Re: Circle2Square Post by: 3dickulus on November 11, 2015, 09:05:07 PM @mclarekin google search "GLSL style math in C++" and you will find exactly what you need.
Some of these are "header only" implementations so no binary libs needed to link with your program. It's as easy as #include somemathlib.h and you will have access to features visual.bermarte describes plus more. Title: Re: Circle2Square Post by: mclarekin on November 11, 2015, 09:14:44 PM Thank you guys
Swizzling (appropriate name :)) is very useful to know about :beer: :beer: :beer:" I will google "GLSL style math in C++" Title: Re: Circle2Square Post by: M Benesi on November 11, 2015, 11:32:55 PM Offhand, does anyone know what I should scale x by to make the tetrahedron generated by the following regular? I'm thinking sqrt(2):
Code: void fullpolytest (inout vec3 z) { Title: Re: Circle2Square Post by: mclarekin on November 12, 2015, 12:50:29 AM These examples use mainly the Benesi cube to sphere transform until bailout. That is probably not how this will be used best, but demonstrates that even with a very heavy influence of this transform, reasonably good image quality can be obtained . Cool. Images are pure cubeSphere, Menger, T1 and PineTree.
Yet another great additional tool for fractal explorers from the Benesi Transform factory ;D :beer: :beer: :beer: Title: Re: Circle2Square Post by: M Benesi on November 12, 2015, 01:26:00 AM Thanks mclarekin,
These examples use mainly the Benesi cube to sphere transform until bailout. Wow. I really like the puffy way those look. I need to try that.... :D I've been.. doing what I always do.. and ended up with something that reminds me of SNES Zelda (or maybe Playstation Alundra?) plants:(https://lh3.googleusercontent.com/-Rn3IjaYbE2o/VkGE-zMdIFI/AAAAAAAADnk/6ONW4e1nPO4/s480-Ic42/garden%2525202.jpg) (https://lh3.googleusercontent.com/-Rn3IjaYbE2o/VkGE-zMdIFI/AAAAAAAADnk/6ONW4e1nPO4/s1024-Ic42/garden%2525202.jpg) That is probably not how this will be used best, but demonstrates that even with a very heavy influence of this transform, reasonably good image quality can be obtained . Cool. It's cool looking anyway. I'm trying what you did after this reply :D.The "unspheric" work well in combination with that one, if you use unspheric, do a calculation, then spheric back to the original coordinate system. It's sort of like rotating to the magnitude axis to do the "abs" part of the formulas... Title: Re: Circle2Square Post by: mclarekin on November 12, 2015, 02:16:52 AM Yep, the unspheric sphereCube transforms is cool also. In fact better in so far as producing detail, which means DE quality is a bit worse. There is so much yet to be tested with all these transforms. But definitely the best results so far, are obtained by exactly how you are using them i.e. PineTrees, T1's and some other bits thrown into the mix. |