On Sep 23, 2006, at 7:08 PM, CV wrote:


On Sep 23, 2006, at 12:09 PM, lveillette wrote:


Let's say I have 3 points, x1,y1(0,0) x2,y2(10,10) and x3y3 (20,0) and I want to draw a curve going from x1,y1 to x3,y3 and pssing thru x2,2...

I tried using the curveShape and x2,y2 as a control point but my line passes
somewhere bewteen y1 and y2

Does someone know how to achive what I would like to do?



I'm not sure I'd use CurveShape for fitting a curve to points, but if I did I'd break it into two CurveShapes, one between x1,y1 and x2, y2 and the other between x2, y2 and x3, y3. Then add suitable control point(s) for each CurveShape, locating them in a way that would pull things into the type of curve fit that you have in mind. I would see some trial and error here, but maybe I'm missing something with respect to using CurveShapes for this.


On reflection, a three point example like yours above only requires one CurveShape. So scratch that part of my answer above. Below is an example, which draws three points and then draws the CurveShape.

Nontheless, I would do this type of problem by fitting a polynomial to the three given points and plotting it using Pixel(x,y). That is straightforward and precise and doesn't raise the issue of placing a control point. If an Object2D is wanted, I'd plot into a picture and fold it into a PixMapShape.

Best regards,

Jack

 Sub Paint(g As Graphics)
  'Draw three points: (0,0), (30,30), (60,0) in cartesian coordinates
  dim Points() as OvalShape
  dim i as integer
  For i = 0 to 2
    Points.Append new OvalShape
    Points(i).Width = 4
    Points(i).Height = 4
  Next
'The coordinates below result from y-downward and translation of origin to X-midpoint of CurveShape
  Points(0).X = -30
  Points(0).Y = 0
  g.DrawObject Points(0), 100, 100
  Points(1).X = 0
  Points(1).Y = -30
  g.DrawObject Points(1), 100, 100
  Points(2).X = 30
  Points(2).Y = 0
  g.DrawObject Points(2), 100, 100

  'Now draw a CurveShape through the three points
  dim c as New CurveShape
  c.X = -30
  c.Y = 0
  c.X2 = 30
  c.Y2 = 0
  c.Order = 1
  c.ControlX(0) = 0
  c.ControlY(0) =  -60  // eyeball this
  g.DrawObject c, 100, 100

End Sub

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to