Repeater line graph

This tends to break as soon as I make further changes (bug report has been submitted) but here’s a proof of concept for a line graph fed by repeater data, made possible by rotation.

Jeff
trend.rp (59.4 KB)

I know this is a long shot because this post is so old, but if you see this, would you mind explaining the math behind this graph to me? It is amazing and I’d love to be able to build off it.

Thanks!

Hi, niki_h. I’ll do my best.

For each segment, the actions are

Move segment to the average of the previous Y value and this one. In the pic, this means the segment gets moved to Y = 30, halfway between 20 and 40. (I changed a few of the values in the original file to round numbers for clarity.)

Set size of the segment to the length it will need to be to stretch from the end of the prior segment to the start of the next one. The segment is the hypotenuse of a right triangle, and the two legs are the width of each column and the change in Y value from the previous to this one. This is the Pythagorean theorem: a^2 + b^2 = c^2. (The y scale is just a multiplier to stretch everything vertically to a pleasing height–try changing it to 2 or 4 and see what happens.)

Rotate the resized segment. This one is probably the most obscure. It uses the arctangent. In a unit circle, the tangent of an angle is the ratio between the opposite side and the adjacent–which happen to be the two legs of the right triangle above. If you know the angle, the tangent gives you the ratio. The arctangent goes the other way: knowing the ratio, it gives us the angle. This step rotates the segment according to this, (anchor center, which is why we moved the segment to the midpoint).

The one hitch with the rotate step is the atan function returns the angle in radians (360° = 2π radians), so that’s where that horrendous 0.01745… number comes in, as a conversion factor.

Hope this helps!

Jeff

2 Likes

Holy smokes. I’ll never know how you figured all that out.

Well, a little trial and error, but it helps that I was a math tutor in college. :slight_smile:

Well that explains it then. Trigonometry was my worst enemy in school!

This has helped me a lot: http://www.carbidedepot.com/formulas-trigright.asp

If you’re familiar with JS the source for that is very simple and it’s easy to see what’s going on behind the scenes.