Math - zziuni/d3 GitHub Wiki

Wiki โ–ธ API Reference โ–ธ Core โ–ธ Math

Pseudorandom Number Generation(์œ ์‚ฌ๋‚œ์ˆ˜ ์ƒ์„ฑ)

๋‚œ์ˆ˜๋ฅผ ๊ท ๋“ฑํ•œ ๋ถ„ํฌ๋กœ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋‚ด์žฅํ•จ์ˆ˜ Math.random๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, 0๊ณผ 99์‚ฌ์ด์—์„œ ์ž„์˜๋กœ ์ •์ˆ˜๋ฅผ ์ƒ์„ฑํ•˜๋Š” ์ฝ”๋“œ๋Š” Math.floor(Math.random() * 100)๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค.

# d3.random.normal([mean, [deviation]])

์ •๊ทœ๋ถ„ํฌ์—์„œ ๋‚œ์ˆ˜๋ฅผ ์ƒ์„ฑํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค. ์ƒ์„ฑ๋  ์œ ์‚ฌ๋‚œ์ˆ˜(pseudorandom numbers) ๊ฐ’์€ ํ‰๊ท ๊ฐ’ mean ์—์„œ ํ‘œ์ค€ํŽธ์ฐจ๊ฐ€ deviation ์ธ ๊ฐ’์ด๋‹ค. deviation ์ธ์ž๊ฐ€ ์—†์œผ๋ฉด 1.0์ด ๊ธฐ๋ณธ๊ฐ’์ด๊ณ , mean ์ธ์ž๊ฐ€ ์—†์œผ๋ฉด 0.0์ด ๊ธฐ๋ณธ๊ฐ’์ด๋‹ค.

# d3.random.logNormal([mean, [deviation]])

Returns a function for generating random numbers with a log-normal distribution. The expected value of the random variableโ€™s natural logrithm is mean, with the given standard deviation. If deviation is not specified, it defaults to 1.0; if mean is not specified, it defaults to 0.0.

# d3.random.irwinHall(count)

Returns a function for generating random numbers with an Irwinโ€“Hall distribution. The number of independent variables is specified by count.

2D Transforms

# d3.transform(string)

SVG์˜ transform attribute์— ์ •์˜๋œ ๊ฒƒ ์ฒ˜๋Ÿผ. ์ฃผ์–ด์ง„ 2D ์•„ํ•€๋ณ€ํ™˜ ๋ฌธ์ž์—ด string ์„ ํŒŒ์‹ฑํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋‚˜์„œ ๊ทธ ๋ณ€ํ™˜์€ translate, rotate, x-skew, scale์˜ ํ‘œ์ค€ํ˜•ํƒœ๋กœ ๋ถ„ํ•ด๋œ๋‹ค. CSS์— ์ด ๊ณผ์ •์ด ํ‘œ์ค€ํ™” ๋˜์–ด์žˆ์œผ๋‹ˆ matrix decomposition for animation๋ฅผ ์ฐธ๊ณ ํ•˜๋ผ.

# transform.rotate

๋ณ€ํ™˜์˜ ํšŒ์ „ ๊ฐ๋„ ฮธ๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค. ๋‹จ์œ„๋Š” ๋„(degrees)๋‹ค.

# transform.translate

๋ณ€ํ™˜์˜ ์ด๋™ [dx, dy]์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค. ์ง€์—ญ ์ขŒํ‘œ๋กœ ์›์ˆ˜๊ฐ€ ๋‘๊ฐœ์ธ ๋ฐฐ์—ด์ด๋‹ค. (๋ณดํ†ต์€ ๋‹จ์œ„๊ฐ€ ํ”ฝ์…€์ด๋‹ค.)

# transform.skew

๋ณ€ํ™˜์˜ x์ถ• ๋น„ํ‹€๋ฆผ(x-skew) ฯ†๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค. ๋‹จ์œ„๋Š” ๋„(degrees)๋‹ค.

# transform.scale

๋ณ€ํ™˜์˜ ์ฒ™๋„(scale) [kx, ky]๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค. ์›์†Œ๊ฐ€ ๋‘๊ฐœ์ธ ๋ฐฐ์—ด์ด๋‹ค.

# transform.toString

๋ณ€ํ™˜ ํ‘œํ˜„ ๋ฌธ์ž์—ด์„ "translate(dx,dy)rotate(ฮธ)skewX(ฯ†)scale(kx,ky)"๊ฐ™์€ ํ˜•ํƒœ๋กœ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

โš ๏ธ **GitHub.com Fallback** โš ๏ธ