Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How Can I get the Coordinate of points on Bezier (Read 1183 times)
bemorem
YaBB Newbies
*
Offline


MacPro Xeon Quad

Posts: 44
Joined: May 3rd, 2007
How Can I get the Coordinate of points on Bezier
Sep 8th, 2009 at 2:43am
Print Post  
How Can I get the Coordinate of points on Bezier Curve?

I mean the Coordinate of Not on ControlPoints But on the Bezier Curve.

And I need just a one mid point of Bezier curve. Not all Points.

Thanks in advance.


  

HW: MacPro Xeon Quad/ 4GB RAM&&OS: WinXP sp3 / .NET 3.5&&Dev: VS 2008 C# sp1&&flowchart .Net ver 4.3.x&&
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How Can I get the Coordinate of points on Bezi
Reply #1 - Sep 8th, 2009 at 7:22am
Print Post  
Call the following method with t = 0.5f and segment = 0:

Code
Select All
static PointF GetBezierPt(PointCollection points, int segment, float t)
{
	float x0 = points[segment * 3 + 0].X;
	float y0 = points[segment * 3 + 0].Y;
	float x1 = points[segment * 3 + 1].X;
	float y1 = points[segment * 3 + 1].Y;
	float x2 = points[segment * 3 + 2].X;
	float y2 = points[segment * 3 + 2].Y;
	float x3 = points[segment * 3 + 3].X;
	float y3 = points[segment * 3 + 3].Y;

	float tt = t;

	float q0 = (1 - tt) * (1 - tt) * (1 - tt);
	float q1 = 3 * tt * (1 - tt) * (1 - tt);
	float q2 = 3 * tt * tt * (1 - tt);
	float q3 = tt * tt * tt;
	float xt = q0 * x0 + q1 * x1 + q2 * x2 + q3 * x3;
	float yt = q0 * y0 + q1 * y1 + q2 * y2 + q3 * y3;

	return new PointF(xt, yt);
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint