3

パス上のノードが「滑らか」になっている場合、 Inkscape が制御点を計算するためにどのアルゴリズム (または式) を使用するのか疑問に思っています。

つまり、d属性が

M 115.85065,503.57451
  49.653441,399.52543 
  604.56143,683.48319 
  339.41126,615.97628 
  264.65997,729.11336

そして、ノードをスムーズに変更すると、d属性が次のように変更されます

M 115.85065,503.57451 
C                     115.85065,503.57451 24.747417,422.50451
  49.653441,399.52543 192.62243,267.61777 640.56491,558.55577
  604.56143,683.48319 580.13686,768.23328 421.64047,584.07809
  339.41126,615.97628 297.27039,632.32348 264.65997,729.11336
  264.65997,729.11336

明らかに、Inkscape はコントロール ポイントの座標を計算します ( の上または後の行の最後から 2 番目と最後の座標ペアC)。Inkscape が使用するアルゴリズムに興味があります。

4

2 に答える 2

5

Inkscape のソース ツリーの src/ui/tool/node.cpp, methodの下に、対応するコードが見つかりましたNode::_updateAutoHandles

void Node::_updateAutoHandles()
{

    // Recompute the position of automatic handles.
    // For endnodes, retract both handles. (It's only possible to create an end auto node
    // through the XML editor.)
    if (isEndNode()) {
        _front.retract();
        _back.retract();
        return;
    }

    // Auto nodes automaticaly adjust their handles to give an appearance of smoothness,
    // no matter what their surroundings are.
    Geom::Point vec_next = _next()->position() - position();
    Geom::Point vec_prev = _prev()->position() - position();
    double len_next = vec_next.length(), len_prev = vec_prev.length();
    if (len_next > 0 && len_prev > 0) {
        // "dir" is an unit vector perpendicular to the bisector of the angle created
        // by the previous node, this auto node and the next node.
        Geom::Point dir = Geom::unit_vector((len_prev / len_next) * vec_next - vec_prev);
        // Handle lengths are equal to 1/3 of the distance from the adjacent node.
        _back.setRelativePos(-dir * (len_prev / 3));
        _front.setRelativePos(dir * (len_next / 3));
    } else {
        // If any of the adjacent nodes coincides, retract both handles.
        _front.retract();
        _back.retract();
    }
}
于 2012-11-16T22:10:35.757 に答える
0

この情報の質については100%確信がありません。しかし、少なくともいくつかの曲線を計算するためのある時点で、inkscapeは>>spiro<<を使用したようです。

http://www.levien.com/spiro/

このページをざっと見てください。彼は博士論文へのリンクを提供しています:http: //www.levien.com/phd/thesis.pdf ここで彼は理論/アルゴリズムを紹介しています...

乾杯

編集:

私は現在、同様の目的でこの問題について少し調査しているので、偶然見つけました... http://www.w3.org/TR/SVG11/paths.html#PathDataCurveCommands...SVGの曲線の仕様。したがって、円や​​円弧ではなく、曲線は3次または2次のベジエです...ベジエの式についてもウィキペディアを参照してください:http: //en.wikipedia.org/wiki/B-spline#Uniform_quadratic_B-spline

于 2012-11-13T15:12:26.510 に答える