2
$\begingroup$

I am working on a Pie Chart, and am using a tutorial that states…

An easy way to get the relative value is to normalize the array and use the normal value [0, 1] to arrive at the angle of the slice, ie. normal * 2 * M_PI. For example, if the normal value is 0.5, the angle of the slice will be M_PI or 180°.

What do they mean, by normal? Ok, so I looked it up (hey, I got a 5 on the Calculus AP, but that was a long time ago).. and realize now that to normalize means to

multiply (a series, function, or item of data) by a factor that makes the norm or some associated quantity such as an integral equal to a desired value (usually 1). • Computing (in floating-point representation) express (a number) in the standard form with regard to the position of the radix point, usually immediately following the first nonzero digit.

OK, so I'm sure I could figure that out.. but again, imagine this is a golden-retriever trying to do this... Going into it, I had imagined I'd be calculating my "slices" like…

10 items = 100% ( item.count / items.total ) * 360 = slice.angle 

Seems simple enough. Maybe too simple. Am I missing something here? Is there a reason that I should be using normalization for this, opposed to something more familiar / simplistic? Thanks.

  • 0
    You want the angle to be `(item.count/items.total)*360`. E.g., with $2$ of $10$ items you want $0.2\cdot 360=72$ degrees, not $0.2/360$ degrees!2012-04-12
  • 0
    Corrected. My golden retriever is an idiot.2012-04-12
  • 0
    When you make that revised calculation, you’re essentially doing what the tutorial suggests: `item.count/items.total` is the normalized value of `item.count`.2012-04-12

1 Answers 1

1

When you calculate the appropriate angle for the segment representing items of Type A, say, as $$\frac{\text{number of items of Type A}}{\text{total number of items}}\cdot 360°\;,$$ you’re doing exactly what the tutorial suggests, because $$\frac{\text{number of items of Type A}}{\text{total number of items}}\tag{1}$$ is the normalized value of $$\text{number of items of Type A}\;.$$ If you have no items of Type A, the fraction $(1)$ is $0$; if every item is of Type A, it’s $1$; if half of the items are of Type A, it’s $0.5$; and so on.