ios - Math behind common geometry shape drawing -
while reading core graphics guide on apple dev library web site. encountered code snippet looks following
cgcontextref context = uigraphicsgetcurrentcontext(); cgfloat size = 20; double r = 0.8 * size / 2; double theta = 2 * m_pi * (2.0 / 5.0); cgcontexttranslatectm(context, size / 2, size / 2); cgcontextmovetopoint(context, 0, r); for(int = 0; < 5; i++){ cgcontextaddlinetopoint(context, r * sin(i * theta), r * cos(i * theta)); } cgcontextclosepath(context);
the above code draw perfect star. question is, know average geometry , trigonometry, know such geometry drawing way? experience , reading lot, or there specific topic 1 should study?
as rex says, trivial application of trig/polar coordinates. if don't understand it, need go , study trig more.
i should have @ minimum strong understanding of high school level geometry, algebra 2, , trigonometry (these days in seem cover trig in "precalculus").
if want 3d graphics should study matrix math. things should give 90% of you'll need.
calculus cool, , liked it, can i've never used in 30+ years of software development. time i've used in trying understand more arcane aspects of fractal mathematics.
Comments
Post a Comment