Tomorrow is the Chinese Valentine's day. For the festival, this article provides several algorithms for heart-shaped surfaces.
Speaking of heart shapes, I think of a joke. A female teacher drew a heart shape on the blackboard and asked the students to add: "What is this? "The students replied," ass. "The teacher cried. He went to the principal's theory. When the principal came, he criticized the students." How did you make the teacher cry again? "Then I saw the pattern on the blackboard and continued:" You are too naughty. Why have you still painted your ass on the blackboard! "
Funny! In fact, I have similar experiences. Someone once said to me, "How do you use your ass as your blog director? "I had to reluctantly answer:" This is not the ass, it is the heart shape, and this heart shape is drawn by a program. "For my heart-shaped Avatar generation algorithm, please refer to my previous blog: Screen Saver: Draw coil lineflower, 3D screen saver: coil, whydemo: Draw coil lineflower.
I also posted a blog a few days ago: Mathematical graphics (1.4) heart-shaped line
I have searched for some materials about the heart-shaped surface, but all of them are the surface of the implicit equation, that is, a mathematical equation is given, and then the figure represented by this equation is a heart-shaped surface. for implicit equations, I will discuss them in detail later. I wrote an implicit equation parsing code from the Internet. it is not easy to use, and it takes a long time to operate. The vertex distribution of the image is a bit messy. as shown in:
Currently, my software tool can only process the surface of the display equation. The following is an algorithm script code for several heart-shaped surfaces I have written:
(1) Heart (circle change)
This was transformed Based on the ball surface.
vertices = dimension1:80 dimension2:160a = from 0 to (2*PI) dimension1b = from (-PI*0.5) to (PI*0.5) dimension2r = 10.0c = sqrt(abs(a - PI))*1.5x = r*cos(b)*sin(a)*cy = -r*cos(b)*cos(a)*cz = r*sin(b)*0.75u = av = b*2y = y - array_min(y)*0.5
(2) sharp heart shape
Curve:
vertices = 1000r = 10.0t = from 0 to (2*PI)p = sin(t)*sqrt(abs(cos(t)))/(sin(t) + 7/5) - 2*sin(t) + 2x = p*sin(t)y = p*cos(t)
Surface:
vertices = D1:360 D2:100r = 10.0u = from 0 to (2*PI) D1v = from (-PI/2) to (PI/2) D2p = sin(u)*sqrt(abs(cos(u)))/(sin(u) + 7/5) - 2*sin(u) + 2x = p*cos(u)y = p*sin(u) + 1.5x = x*cos(v)y = y*cos(v)z = 0.8*sin(v)
(3) perfect heart shape
This is the most perfect heart shape I have ever generated.
Curve:
vertices = 360u = from (-PI) to (PI)w = abs(u)p = w*sqrt(w/(1 + w))x = p*sin(u)y = (p*cos(u) + 1)*0.9
Plane:
vertices = D1:360 D2:100u = from (-PI) to (PI) D1v = from 1 to 100 D2w = abs(u)p = w*sqrt(w/(v + w))x = p*sin(u)y = p*cos(u)*0.9
Surface:
vertices = D1:360 D2:64u = from (-PI) to (PI) D1v = from (PI/2) to (-PI/2) D2w = abs(u)p = w*sqrt(w/(1 + w))b = 0.5x = p*sin(u)*cos(v)y = (p*cos(u) + 0.9)*0.9*cos(v)z = b*sin(v)
If you think this heart shape is still like an ass, you will find it different from the figure below.
(4) heart shaped like ass
#http://xahlee.info/surface/kuen/kuen.htmlvertices = D1:100 D2:100u = from (-1.4325*PI) to (1.4325*PI) D1v = from (-10) to (10) D2w = (cosh[v]^2 + u^2)x = 2*cosh[v]*(cos[u] + u*sin[u])z = 2*cosh[v]*(-u*cos[u] + sin[u])y = v - (2*sinh[v]*cosh[v])x = x/wy = y/wz = z/w