x, y, z = pos
radius = width / 2.0
if width >= 0.0:
    x = -x
a = radius * math.pi
a = (x/a) * math.pi

This is a code snippet from someone other than me, and I've been wanting to understand it. However, the variable a is a little ambiguous, and I'm having trouble figuring out its purpose.

This snippet is part of a function that calculates an arch that text will be displayed over.

The variable pos is the position of the current letter we are working with. The variable width is the width of the entire line.

有帮助吗?

解决方案

There is nonsense usage of math.pi - result doesn't depend on it.
a = x/R = Cos(Fi), where Fi is direction angle of (coordinate origin - starting point) vector, if R is radius of arc with origin as center

(Cos(Fi) negated for positive width values)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top