Re: Calculating Control Points For Bsplines

Lawrence D'Oliveiro <[email protected]>
Newsgroups gmane.comp.lib.cairo
Organization Geek Central
Message-ID <[email protected]>
On Sat, 12 Dec 2015 08:25:30 +0100, Bernhard Fischer wrote:

> I wrote an article about calculating control points for Bsplines
> (based on polygons) and a sample program.

Always interested to see how people use geometrical calculations
together with Cairo. Just some points:

I had to deal with the same issue of calculating half the
difference between two angles in this
<https://github.com/ldo/qahirah_examples/blob/master/pattern_dash>
piece of example code (output here
<http://default-cube.deviantart.com/art/Pattern-Dash-576369003>),
while avoiding discontinuities around 0°. The calculation I came up with
was basically

    ((angle2 - angle1 + π) mod 2π - π) ÷ 2

Also, C, like most IEEE-754-compliant languages, has a built-in function
for calculating Euclidean distance. Instead of

    s = sqrt(pow(a, 2) + pow(b, 2))

why not just write

    s = hypot(a, b)

Another idea is, when averaging the angles at the corners, why not
weight the contributions from the adjacent line segments according to
their relative lengths? So shorter segments will produce sharper curves.
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.