|
Post by tenochtitlanuk on Mar 26, 2022 3:43:33 GMT -5
With the egg-citing approach of Easter and its association with eggs- decorated ones ( pretty!)- and chocolate ones ( yes please!) you may have missed news that mathematicians have cracked ( !) the problem of describing all egg shapes with a single equation. Previously they could only do so for circles, ovals, or ovals with the long axis distorted to bias the fattest point towards one end. This unfortunately does not cover the more pear-shaped eggs. We won't beat Anatoly's ( tsh) Faberge eggs, but still fun to have. Do a Google search and work from there. Some ideas.. A single outline? Eggs in arrays or circles? Eggs in a basket? Varying sizes? Colour schemes- single colour or gradient fill? 3D eggs as rotatable 2d line projections?
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Mar 26, 2022 12:39:41 GMT -5
Yes I see they have a formula now:
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Mar 26, 2022 12:59:10 GMT -5
Just figured how to shade a little bit:
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Mar 26, 2022 13:09:44 GMT -5
And a little background:
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Mar 26, 2022 14:33:58 GMT -5
But can he draw more than one? yes
|
|
|
Post by Carl Gundel on Mar 26, 2022 15:04:02 GMT -5
Now mix that with the ray tracing code that was recently posted.
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Mar 26, 2022 17:15:37 GMT -5
hmm...I'll look into it.
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Mar 27, 2022 10:31:12 GMT -5
Hint #1:
I only needed the eq who knows what a type t3 exponential eq is?
Then I moved the 1 from right side of eq and I ran x and y loops and found when the plug in x, y was nearly 0 ie <= .01.
Then I scaled (x,y) and shifted the pixel sets by the screen center to graph results on JB/LB screen. That's when things shaped up.
Using a 500 X 500 screen setup, the code looks like this:
for x = -1 to 1 step .01 ' i reversed x, y order for coloring for y = -1 to 1 step .01 scan if ( x*x + (1.4 ^ x * 1.6 * y) ^ 2 - 1 ) <= .01 then #gr "color blue" #gr "set ";scale * x + 250;" ";scale * y + 250 end if 'if (x * x + y * y - 1) <= .01 then 'test a known figure a circle '#gr "color red" '#gr "set ";scale * x + 250;" ";scale * y + 250 'end if next next
The 250's put x= 0 and y=0 right in the center of the graphics screen. Scale just expands or shrinks the plot.
Wouldn't it be nice if author of Ray Tracing could come and explain their code step by step?
|
|
|
Post by Brandon Parker on Mar 27, 2022 12:27:11 GMT -5
A "T3" equation is most likely a "Third Taylor Polynomial" ...
{:0)
Brandon Parker
|
|
|
Post by Rod on Mar 27, 2022 12:59:44 GMT -5
Might be difficult since the sphere to sphere collision is well understood. The egg is neither a plane nor a sphere and in 3d it would be hard to know what part of the egg you hit. The best tutorial I have found is here raytracing.github.io/books/RayTracingInOneWeekend.html
|
|
|
Post by Carl Gundel on Mar 28, 2022 6:31:09 GMT -5
Might be difficult since the sphere to sphere collision is well understood. The egg is neither a plane nor a sphere and in 3d it would be hard to know what part of the egg you hit. The best tutorial I have found is here raytracing.github.io/books/RayTracingInOneWeekend.htmlJust use brute force and make the eggs out of millions of microspheres. ;P It would take a loooooong time to do the processing.
|
|
|
Post by tsh73 on Mar 28, 2022 7:28:53 GMT -5
How about just 7? Just put those DATA lines in 'nomainwin open "egg" for graphics_nsb_nf as #gr #gr "trapclose [quit]" #gr "down; home; posxy cx cy"
pi=acs(-1) pi2=2*pi x0=70:xk=cx*2-100 print "data 7" for i = 0 to 6 x=x0+i/6*(xk-x0) #gr "place ";x;" ";cy r = sin((i+2)/pi2*1.5)*80 #gr "circle ";r print "data ";x/80*.4-.5;",";-0.6;",";1.5;",";r/80*.4 next
#gr "flush" wait
[quit] close #gr end
|
|
|
Post by Rod on Mar 28, 2022 10:22:23 GMT -5
Wow. Falls over in disbelief!!
|
|
|
Post by Carl Gundel on Mar 28, 2022 10:25:06 GMT -5
How about just 7? Just put those DATA lines in 'nomainwin open "egg" for graphics_nsb_nf as #gr #gr "trapclose [quit]" #gr "down; home; posxy cx cy"
pi=acs(-1) pi2=2*pi x0=70:xk=cx*2-100 print "data 7" for i = 0 to 6 x=x0+i/6*(xk-x0) #gr "place ";x;" ";cy r = sin((i+2)/pi2*1.5)*80 #gr "circle ";r print "data ";x/80*.4-.5;",";-0.6;",";1.5;",";r/80*.4 next
#gr "flush" wait
[quit] close #gr end
Love it! Just need a higher sampling rate to make it more convincing, but wow, nice!
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Mar 28, 2022 11:23:47 GMT -5
A little more brute force! Modifying tsh73 egg drawing and data making: 'nomainwin open "egg" for graphics_nsb_nf as #gr #gr "trapclose [quit]" #gr "down; home; posxy cx cy"
'#gr "size 2" pi=acs(-1) pi2=2*pi x0=70:xk=cx*2-100 print "data 49" #gr "color 255 160 200" #gr "backcolor 255 160 200" for i = 0 to 6 step .125 x=x0+i/7*(xk-x0) #gr "place ";x;" ";cy r = sin((i+2)/pi2*1.5)*80 #gr "circlefilled ";r print "data ";x/80*.4-.5;",";-0.6;",";1.5;",";r/80*.4 next '#gr "color 0 0 200" '#gr "backcolor 0 0 200" 'for i = 0 to 6 ' x=x0+i/6*(xk-x0) ' #gr "place ";x;" ";cy ' r = sin((i+2)/pi2*1.5)*80 ' #gr "circle ";r ' print "data ";x/80*.4-.5;",";-0.6;",";1.5;",";r/80*.4 'next
#gr "flush" wait
[quit] close #gr end
|
|