Skip to main content
Inspiring
January 21, 2016
Answered

RealBezier-> Divide works incorrectly

  • January 21, 2016
  • 1 reply
  • 578 views

What I'm tryin to do is to divide  a path into 2 equal parts using RealBezier methods.

That's a sample code:

AIRealBezier b0, b1, b2;

error = sAIPath-> GetPathBezier (path, 0, &b0);

sAIRealBezierSuite-> Divide (&b0, 0.5, &b1,&b2); // t=0.5, gonna divide in half

Then I assign bezier control points to segments like this:

segment.p.h = b1.p0.h;

segment.p.v = b1.p0.v;

//and so on

OK, looks good. Works fine with straight lines and symmetrical segments.

BUT! If there's difference in length of handles (I mean 1st handle is huge, 2nd - tiny), result turns out to be incorrrect (parts are obviously not equal).

Though it produces smooth result which means that "assigning bezier control points to segments" is done  in a right way.

Is it normal behaviour of RealBezier Divide?

This topic has been closed for replies.
Correct answer JLGJeanLouis

I think that the divide function works correctly.

//To divide the curve in two equal parts, I first find the length of the bezier segment.

AIRealBezier b0, b1;

error=sAIPath->GetPahtBezier(path, 0, &b0);

LengthOfTheBezierSegment=sAIBezier->Length(&b0, 1.0);

//I use this length to find the good value of t.

//LengthOfTheBezierSegment*0.5 is to have the middle of the bezier segment.

error=sAIBezier->TAtLength(&b0, LengthOfTheBezierSegment, LengthOfTheBezierSegment*0.5, 1.0, &t);

JLG.

1 reply

JLGJeanLouisCorrect answer
Inspiring
January 21, 2016

I think that the divide function works correctly.

//To divide the curve in two equal parts, I first find the length of the bezier segment.

AIRealBezier b0, b1;

error=sAIPath->GetPahtBezier(path, 0, &b0);

LengthOfTheBezierSegment=sAIBezier->Length(&b0, 1.0);

//I use this length to find the good value of t.

//LengthOfTheBezierSegment*0.5 is to have the middle of the bezier segment.

error=sAIBezier->TAtLength(&b0, LengthOfTheBezierSegment, LengthOfTheBezierSegment*0.5, 1.0, &t);

JLG.