From: cilix42 Date: Mon, 19 May 2008 16:14:14 +0000 (+0000) Subject: Add possibility to let the 'tangent' have a fixed angle relative to the curve X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=967848f1f8f64b989f1c28f9d57d068bbfb9384c;p=inkscape.git Add possibility to let the 'tangent' have a fixed angle relative to the curve --- diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index 92aca33c6..65948837f 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -22,6 +22,7 @@ #include "libnr/n-art-bpath-2geom.h" #include <2geom/path.h> +#include <2geom/transforms.h> namespace Inkscape { namespace LivePathEffect { @@ -95,11 +96,13 @@ LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) : Effect(lpeobject), t_attach(_("Location along curve"), _("Location of the point of attachment along the curve (between 0.0 and number-of-segments)"), "t_attach", &wr, this, 0.5), length_left(_("Length left"), _("Specifies the left end of the tangent"), "length-left", &wr, this, 150), - length_right(_("Length right"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150) + length_right(_("Length right"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150), + angle(_("Angle"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0) { registerParameter( dynamic_cast(&t_attach) ); registerParameter( dynamic_cast(&length_left) ); registerParameter( dynamic_cast(&length_right) ); + registerParameter( dynamic_cast(&angle) ); registerKnotHolderHandle(attach_pt_set, attach_pt_get); registerKnotHolderHandle(left_end_set, left_end_get); registerKnotHolderHandle(right_end_set, right_end_get); @@ -118,6 +121,10 @@ LPETangentToCurve::doEffect_pwd2 (Geom::Piecewise > const ptA = pwd2_in.valueAt(t_attach); derivA = unit_vector(derivative(pwd2_in).valueAt(t_attach)); + // TODO: Why are positive angles measured clockwise, not counterclockwise? + Geom::Rotate rot(Geom::Rotate::from_degrees(-angle)); + derivA = derivA * rot; + C = ptA - derivA * length_left; D = ptA + derivA * length_right; diff --git a/src/live_effects/lpe-tangent_to_curve.h b/src/live_effects/lpe-tangent_to_curve.h index 7d80b23bb..3bddc11fb 100644 --- a/src/live_effects/lpe-tangent_to_curve.h +++ b/src/live_effects/lpe-tangent_to_curve.h @@ -45,6 +45,8 @@ private: ScalarParam length_left; ScalarParam length_right; + ScalarParam angle; + Geom::Point ptA; // point of attachment to the curve Geom::Point derivA;