ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TIELineLayer relationship to radius
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

NotTooSmart

USA
12 Posts

Posted - Jun 25 2021 :  15:19:27  Show Profile  Reply
Var c can have a range value, for example, from 8 to 0.02 See this statement:
TIELineLayer(ImageEnView1.CurrentLayer).Curve := c;

This produces an arc. My question is what is the math relationship between the c value and the radius of the arc created? Thanks for any advice.

Jorge

xequte

38185 Posts

Posted - Jun 25 2021 :  20:37:01  Show Profile  Reply
Hi Jorge

Unfortunately there is not a precise relationship between c and radius.

c = 1: Creates a curve of an exact half circle.
c > 1: Creates a shallower curve.
c < 1: Creates a bulging curve.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38185 Posts

Posted - Jun 25 2021 :  22:41:24  Show Profile  Reply
This method may help:

// Given two points, and a point on the circle radius, return the multiplier (e.g. TIELineLayer.Curve)
// Result will be negative for inverted curves
function CalculateRadiusMultiplier(Pt1, Pt2, RadiusPt: TPoint; ForceHalfCircle: Boolean = False): Double;
var
  midPt: TPoint;
  abVect, azVect, ptDelta, rad: Double;
  isCW: Boolean;
begin
  midPt.x := min( Pt1.x, Pt2.x ) + abs( Pt1.x - Pt2.x ) div 2;
  midPt.y := min( Pt1.y, Pt2.y ) + abs( Pt1.y - Pt2.y ) div 2;

  abVect := IERadiansToDegrees( IEAngle2( Pt1.X, Pt1.y, Pt2.X, Pt2.Y  ));
  azVect := IERadiansToDegrees( IEAngle2( Pt1.X, Pt1.y, RadiusPt.X, RadiusPt.Y ));
  if abVect >= 180 then
    isCW := ( azVect > abVect ) or ( azVect < abVect - 180 )
  else
    isCW := ( azVect > abVect ) and ( azVect < abVect + 180 );

  ptDelta := IEDistPoint2Point( Pt1.X, Pt1.Y, Pt2.X, Pt2.Y );
  rad := IEDistPoint2Point( midPt.X, midPt.Y, RadiusPt.X, RadiusPt.Y );

  if ForceHalfCircle then
    Result := 1
  else
    Result := 1 / ( rad / ptDelta * 2 );
  if isCW then
    Result := -Result;
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

NotTooSmart

USA
12 Posts

Posted - Jun 28 2021 :  13:21:54  Show Profile  Reply
Thanks Nigel,
When I tried to compile the function CalculateRadiusMultiplier... in the above message, it produced an error.
It did not recognize 'min' in midPt.x := min( Pt1.x, Pt2.x ) + abs( Pt1.x - Pt2.x ) div 2;
Please advice
Thanks

Jorge
Go to Top of Page

xequte

38185 Posts

Posted - Jun 29 2021 :  16:37:35  Show Profile  Reply
Hi Jorge

Min is defined in the Delphi math unit:

http://docwiki.embarcadero.com/Libraries/Sydney/en/System.Math.Min


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: