OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-11-2005, 10:30
Pickuptrucker
Guest
 
Posts: n/a
Question 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!
Reply With Quote
  #2  
Old 03-11-2005, 12:41
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

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

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.
Reply With Quote
  #4  
Old 06-11-2005, 21:25
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

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
Reply With Quote
Reply


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

Advanced Search
Display Modes

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 Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bending shapes to match a curve jemmyell CorelDRAW/Corel DESIGNER VBA 0 01-11-2005 23:54
Print problem of create curve petu CorelDRAW/Corel DESIGNER VBA 5 25-05-2005 21:02
The formula of crossing direct from a curve Bezier is necess drg CorelDRAW/Corel DESIGNER VBA 2 26-09-2004 09:27
Tone Curve in PP12 Michael Cervantes Corel Photo-Paint VBA 2 06-04-2004 13:00
New user - curve default? - dxf conversion? Anonymous CurveWorks 2 16-05-2003 10:23


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


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com