OberonPlace.com Forums > VBA Points on curve
 Blogs Gallery FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

#1
02-11-2005, 10:30
 Pickuptrucker Guest Posts: n/a
Points on curve

Hi! Is there any method to calculate the X/Y coordinates of points lying on a curve shape? I searched the API but cannot find anything like "ConvertToPolygonPoints" or something similar.
I just would like to select a curve shape, specify a number of points to calculate and the macro creates a list of X/Y values representing the selected curve. Any hints highly appreciated. Many thanks in advance!
#2
03-11-2005, 12:41
 Alex Administrator Join Date: Nov 2002 Posts: 1,940 Blog Entries: 4

Look at SubPath.GetPointPositionAt method.
#3
04-11-2005, 06:21
 Pickuptrucker Guest Posts: n/a

Many thanks! Your hint seems to be the right direction so I can forget about implementing my own cubic bezier function for calculating x/y values on curve segments !
However, if someone is interested in, here is the C# source for a similar function like GetPointPositionAt working in 3D:

private Point3D CubicBezier(Point3D p0,Point3D p1,Point3D p2,Point3D p3,double mu)
{
// p0 = StartNode, p1 = StartControlPoint, p2 = EndControlPoint, p3 = EndNode
Point3D a = new Point3D();
Point3D b = new Point3D();
Point3D c = new Point3D();
Point3D p = new Point3D();

c.x = 3 * (p1.x - p0.x);
c.y = 3 * (p1.y - p0.y);
c.z = 3 * (p1.z - p0.z);
b.x = 3 * (p2.x - p1.x) - c.x;
b.y = 3 * (p2.y - p1.y) - c.y;
b.z = 3 * (p2.z - p1.z) - c.z;
a.x = p3.x - p0.x - c.x - b.x;
a.y = p3.y - p0.y - c.y - b.y;
a.z = p3.z - p0.z - c.z - b.z;

p.x = a.x * mu * mu * mu + b.x * mu * mu + c.x * mu + p0.x;
p.y = a.y * mu * mu * mu + b.y * mu * mu + c.y * mu + p0.y;
p.z = a.z * mu * mu * mu + b.z * mu * mu + c.z * mu + p0.z;

return p;
}

Use the segments' StartNode X/Y values as parameter p0, the segments' StartingControlPointX/Y as parameter p1, the EndingControlPointX/Y as p2 and finally the EndNode X/Y values as p3. Specify the paramter mu (distance from the startpoint) as value between 0..1. The function returns the X/Y/Z values of the point on the curve.
This is applicable for most vector drawing software like Freehand, Flash, etc.
#4
06-11-2005, 21:25
 Alex Administrator Join Date: Nov 2002 Posts: 1,940 Blog Entries: 4

Or generally, cubic Bezier is described by the following formula:

f(t) = p1 * (1-t)^3 + 3 * p2 * (1-t)^2 * t + 3 * p3 * (1-t) * t^2 + p4 * t^3

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home OberonPlace Discussion     Site News     Web site suggestions     Image Gallery     Testing Oberon Products     CurveWorks     SecuriDesign     Calendar Wizard     Oberon Function Plotter     Jigsaw Puzzle Creator     Other Oberon Commercial Products     New product ideas Corel User Forums     CorelDRAW         General         Tutorials         FAQ         Feature requests/wishlist         Macros/Add-ons         Artwork Showcase     Corel DESIGNER         General         Tutorials         FAQ         Feature requests/wishlist         Macros/Add-ons         Artwork Showcase     Corel PHOTO-PAINT         General         Tutorials         FAQ         Feature requests/wishlist         Macros/Add-ons         Artwork Showcase     General         About Corel         Off-Topic Developer Forums     OberonPlace Development Portal     VBA         CorelDRAW/Corel DESIGNER VBA         Corel Photo-Paint VBA         Code Critique     Corel Script         CorelDRAW CS         Corel Photo-Paint CS

 Similar Threads Thread Thread Starter Forum Replies Last Post jemmyell CorelDRAW/Corel DESIGNER VBA 0 01-11-2005 23:54 petu CorelDRAW/Corel DESIGNER VBA 5 25-05-2005 21:02 drg CorelDRAW/Corel DESIGNER VBA 2 26-09-2004 09:27 Michael Cervantes Corel Photo-Paint VBA 2 06-04-2004 13:00 Anonymous CurveWorks 2 16-05-2003 10:23

All times are GMT -5. The time now is 13:37.

 OberonPlace.com - Archive - Top