Bug or feature?

83 views
Skip to first unread message

Евгений Хорев

unread,
Apr 6, 2013, 5:11:32 AM4/6/13
to pap...@googlegroups.com
When for existing path I do

path.segments[0].point = p0;
path.segments[0].handleOut = {angle: alpha, length: l};

it works as expected,
but when I do

path.segments[0].point = p0;
path.segments[0].handleOut.angle = alpha;
path.segments[0].handleOut.length = l;


it changes the handle’s direction to opposite for the same ‘alpha’ and ‘l’ values in some cases, totally unpredictable for me.
Is it bug or did I miss something?

Jürg Lehni

unread,
Apr 15, 2013, 1:55:19 AM4/15/13
to pap...@googlegroups.com
Could you please provide a case where the error happens, so we can look into it? Thanks!
> --
> You received this message because you are subscribed to the Google Groups "Paper.js" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Евгений Хорев

unread,
Apr 15, 2013, 2:00:45 PM4/15/13
to pap...@googlegroups.com
Just checked one more time:

        connPath.segments[0].point = P0;
        //connPath.segments[0].handleOut = {
        //    angle: (Alpha - alpha0) * 180 / Math.PI + 90,
        //    length: l0
        //};
        connPath.segments[0].handleOut.angle = (Alpha - alpha0) * 180 / Math.PI + 90;
        connPath.segments[0].handleOut.length = l0;

Changing commented lines for last two ones makes it rotate vector to opposite direction for some values of it.
If it worth i could provide whole my code ~400 lines.

понедельник, 15 апреля 2013 г., 7:55:19 UTC+2 пользователь Jürg Lehni написал:

Jürg Lehni

unread,
Apr 15, 2013, 9:05:47 PM4/15/13
to pap...@googlegroups.com
Well we would simply need one path with coordinates where this happens.

Евгений Хорев

unread,
May 5, 2013, 5:25:49 PM5/5/13
to pap...@googlegroups.com
Sorry for the late reply!

Mentioned direction changes occurs with negative handle's values.

Didn't figured it out earlier because the drawing is preceded with nice chunk of trigonometry,
so the vector with a negative length and rotated by pi is the same vector.
And then this math, which captured all of my attention, is somehow friendshipped with paperjs library.

Anyway, here's a code snippet demonstrating difference in behavior:

http://jsfiddle.net/DMKWH/


вторник, 16 апреля 2013 г., 3:05:47 UTC+2 пользователь Jürg Lehni написал:

Евгений Хорев

unread,
Jun 22, 2013, 1:22:21 PM6/22/13
to pap...@googlegroups.com
Rose up to 0.9.4 and still there )

Jürg Lehni

unread,
Jun 23, 2013, 8:19:47 PM6/23/13
to pap...@googlegroups.com
After looking into this a bit more, I decided this is not actually a bug:


var point1 = new Point();
point1.angle = -45;
point1.length = -Math.sqrt(2);
// { x: -1, y: 1 }

var point2 = new Point(0, 0);
point2.length = -Math.sqrt(2);
point2.angle = -45;
// { x: 1, y: -1 }

Setting the length to negative values does not really make sense unless the vector already holds a value, in which case the effect is that it flips direction.

This is why in one version you don't see reversed vectors, and in the other you do.

If you make sure your length is never negative, this should not happen.

Best,

J

On Jun 22, 2013, at 10:22 , Евгений Хорев <khorev...@gmail.com> wrote:

> Rose up to 0.9.4 and still there )
>
Reply all
Reply to author
Forward
0 new messages