incubator-ooo-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 115917] tools: bezier curve drawing and smoothness
Date Fri, 27 Jul 2012 16:25:18 GMT
https://issues.apache.org/ooo/show_bug.cgi?id=115917

--- Comment #6 from Armin Le Grand <Armin.Le.Grand@me.com> ---
ALG: And again: For C1, mediating direction weighted by length may be even
better, this gives vector addition to get the common direction.
This leads to unification of calculating the common direction for C1 and C2
cases for correction. Proposed code:

            // extract the point and vectors
            const basegfx::B2DPoint aPoint(roPolygon.getB2DPoint(nIndex));
            const basegfx::B2DVector
aNext(roPolygon.getNextControlPoint(nIndex) - aPoint);
            const basegfx::B2DVector aPrev(aPoint -
roPolygon.getPrevControlPoint(nIndex));

            // calculate common direction vector, normalize
            basegfx::B2DVector aDirection(aNext + aPrev);
            aDirection.normalize();

            if(POLY_SMOOTH == nCFlag)
            {
                // C1: use common direction vector, preserve individual lengths
                roPolygon.setNextControlPoint(nIndex, basegfx::B2DPoint(aPoint
+ (aDirection * aNext.getLength())));
                roPolygon.setPrevControlPoint(nIndex, basegfx::B2DPoint(aPoint
- (aDirection * aPrev.getLength())));
            }
            else // POLY_SYMMTR
            {
                // C2: get mediated length. Taking half of the unnormalized
direction would be
                // an approximation, but not correct. Create common vector in
direction next.
                const double fMedLength((aNext.getLength() + aPrev.getLength())
* 0.5);
                const basegfx::B2DVector aCommonNext(aDirection * fMedLength);

                // use common vector
                roPolygon.setNextControlPoint(nIndex, basegfx::B2DPoint(aPoint
+ aCommonNext));
                roPolygon.setPrevControlPoint(nIndex, basegfx::B2DPoint(aPoint
- aCommonNext));
            }

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Mime
View raw message