Skip to main content

Exercise 3.4

Calculationโ€‹

3_1_vnoiseGrad.frag ใงใฏใ€้–ขๆ•ฐ vnoise21() ใ‚’ๆ•ฐๅ€คๅพฎๅˆ†ใ—ใฆๅ‹พ้…ใ‚’ๆฑ‚ใ‚ใฆใ„ใŸใŒใ€ใ“ใฎๆผ”็ฟ’ๅ•้กŒใงใฏใ€ๅŒ้–ขๆ•ฐใ‚’่งฃๆžๅพฎๅˆ†ใ™ใ‚‹ใ“ใจใงใ€ๅ‹พ้…ใ‚’ๆฑ‚ใ‚ใฆใฟใŸใ„ใ€‚

ใพใšใ€้–ขๆ•ฐ vnoise21() ใฎๅ†…้ƒจใ‚’ๆ”นใ‚ใฆ็ขบ่ชใ™ใ‚‹ใจใ€ไธŽใˆใ‚‰ใ‚ŒใŸ2ๆฌกๅ…ƒใƒ™ใ‚ฏใƒˆใƒซpใซๅฏพใ—ใ€pใ‹ใ‚‰็”Ÿๆˆใ•ใ‚Œใ‚‹4ใคใฎใƒใƒƒใ‚ทใƒฅๅ€ค(v[0], v[1], v[2], v[3])ใŠใ‚ˆใณใ‚จใƒซใƒŸใƒผใƒˆ่ฃœ้–“้–ขๆ•ฐใง่ฃœ้–“ใ•ใ‚ŒใŸๅ„ๆฌกๅ…ƒใ”ใจใฎๅ€ค(f[0], f[1])ใ‚’ไฝฟใฃใฆใ€ไปฅไธ‹ใฎๅ€คใ‚’่ฟ”ใ™ใ‚‚ใฎใงใ‚ใ‚‹ใ€‚

return mix(mix(v[0], v[1], f[0]), mix(v[2], v[3], f[0]), f[1]);

ไปฅ้™ใงใ“ใ‚Œใ‚’ๆ•ฐๅผใง่กจ่จ˜ใ™ใ‚‹ใŸใ‚ใ€ไปฅไธ‹ใฎๆง˜ใซ็ฝฎใๆ›ใˆใฆ่€ƒใˆใ‚‹ใ“ใจใซใ™ใ‚‹ใ€‚

  • vnoise21(p)้–ขๆ•ฐ: V(x,y)V(x, y)
  • 4ใคใฎใƒใƒƒใ‚ทใƒฅๅ€ค(v[0], v[1], v[2], v[3]): v0,v1,v2,v3v_0, v_1, v_2, v_3
  • ใ‚จใƒซใƒŸใƒผใƒˆ่ฃœ้–“้–ขๆ•ฐ: h()h()

ใ•ใฆใ€V(x,y)V(x, y) ใฎๅฎŸ่ฃ…ใ‚’็ด ็›ดใซๆ•ฐๅผใง่กจ็พใ™ใ‚‹ใจใ€

V(x,y)=mix(mix(v0,v1,h(x)),mix(v2,v3,h(x)),h(y));(ex3.4.1)\tag{ex3.4.1} V(x,y) =\text{mix}( \text{mix}(v_0, v_1, h(x)), \text{mix}(v_2, v_3, h(x)), h(y));

ใงใ‚ใ‚‹ใ€‚ใ“ใฎ(ex3.4.1)ๅผใฎๅณ่พบใซ็™ปๅ ดใ™ใ‚‹ mix\text{mix} ใ‚’่จˆ็ฎ—ใ—ใฆใŠใใจ

mix(v0,v1,h(x))=v0(1โˆ’h(x))+v1h(x)=v0+h(x)(v1โˆ’v0)mix(v2,v3,h(x))=v2(1โˆ’h(x))+v3h(x)=v2+h(x)(v3โˆ’v2)(ex3.4.2)\tag{ex3.4.2} \begin{array}{c} \text{mix}(v_0, v_1, h(x)) = v_0(1 - h(x)) + v_1 h(x) = v_0 + h(x)(v_1 - v_0) \\ \text{mix}(v_2, v_3, h(x)) = v_2(1 - h(x)) + v_3 h(x) = v_2 + h(x)(v_3 - v_2) \end{array}

ใจใชใ‚‹ใฎใงใ€ๆ”นใ‚ใฆ(ex3.4.1)ๅผใจ(ex3.4.2)ๅผใ‚ˆใ‚Š V(x,y)V(x, y) ใฏไปฅไธ‹ใฎๆง˜ใซ่จ˜่ฟฐใ™ใ‚‹ใ“ใจใŒใงใใ‚‹ใ€‚

V(x,y)=(v0+h(x)(v1โˆ’v0))(1โˆ’h(y))+(v2+h(x)(v3โˆ’v2))h(y)=a+bh(x)+ch(y)+dh(x)h(y)\begin{align*} V(x,y) &= (v_0 + h(x)(v_1 - v_0))(1-h(y)) + (v_2 + h(x)(v_3 - v_2) )h(y) \\ &= a + bh(x) + ch(y) + dh(x)h(y) \end{align*}

ใŸใ ใ—ใ€ใ“ใ“ใง

a=v0b=โˆ’v0+v1c=โˆ’v0+v2d=v0โˆ’v1โˆ’v2+v3(ex3.4.3)\tag{ex3.4.3} \begin{align*} a &= v_0 \\ b &= - v_0 + v_1 \\ c &= - v_0 + v_2 \\ d &= v_0 - v_1 - v_2 + v_3 \end{align*}

ใงใ‚ใ‚‹

ใ•ใฆใ€ใ“ใฎ V(x,y)V(x,y) ใ‚’ xx, yy ใงใใ‚Œใžใ‚Œๅๅพฎๅˆ†ใ™ใ‚‹ใจใ€

โˆ‚โˆ‚xV(x,y)=hโ€ฒ(x)(b+dh(y))\frac{\partial}{\partial x} V(x,y) = h'(x)(b + dh(y)) \\
โˆ‚โˆ‚yV(x,y)=hโ€ฒ(y)(c+dh(x))\frac{\partial}{\partial y} V(x,y) = h'(y)(c + dh(x))

ใจใชใ‚‹ใ€‚ ใคใพใ‚Šใ€(ex3.4.3)ๅผใฎ bb, cc, dd ใจใ‚จใƒซใƒŸใƒผใƒˆ้–ขๆ•ฐ hh ใŠใ‚ˆใณใใฎๅฐŽ้–ขๆ•ฐ hโ€ฒh' ใ‚’็”จใ„ใ‚Œใฐใ€ๅ‹พ้… gradV\text{grad}V ใฏ

gradV(x,y)=(hโ€ฒ(x)(b+dh(y)),hโ€ฒ(y)(c+dh(x)))\text{grad}V(x,y) = ( h'(x)(b + dh(y)), h'(y)(c + dh(x)) )

ใจ่กจ็พใงใใ‚‹ใ“ใจใŒใ‚ใ‹ใฃใŸใ€‚

Verificationโ€‹

ไธŠ่จ˜ใงๅพ—ใ‚‰ใ‚ŒใŸๅ‹พ้…ใ‚’ใƒ—ใƒญใ‚ฐใƒฉใƒ ใงๅฎŸ่ฃ…ใ—ใŸใ„ใ€‚ ใชใŠใ€ใ‚จใƒซใƒŸใƒผใƒˆ้–ขๆ•ฐใฎๅฐŽ้–ขๆ•ฐใŒไปฅไธ‹ใงใ‚ใ‚‹ใ“ใจใ‚’ๅˆฉ็”จใ—ใฆใ„ใ‚‹ใ€‚

h(x)=3x2โˆ’2x3โ‡’hโ€ฒ(x)=6(xโˆ’1)h(x)=6x5โˆ’15x4+10x3โ‡’hโ€ฒ(x)=30x2(x2โˆ’2x+1)\begin{align*} h(x) = 3x^2 - 2x^3 &\Rightarrow h'(x) = 6(x - 1) \\ h(x) = 6x^5 - 15x^4 + 10x^3 &\Rightarrow h'(x) = 30x^2(x^2 - 2x + 1) \end{align*}
exercise_3_4.frag