Hello,
I am trying to use the subdivide(double t, Cubic c0, Cubic c1) method
in Cubic package.
This method - seems - not to compute sub segment control points properly
(except for mid-value t=0.5).
I'm not very keen in Bezier, casteljau algorithms, could someone lend me
a hand on this ?
For info the same method in Quadradic package works well.
Thanks for any input and/or help !
-- Franck
Below a small Java2D program showing 3 curves: original curve in red, [0
to 0.8] sub in blue and [0,0.3] sub in green.
--------- Cut here
------------------------------------------------------------------------
public static void main(String args[])
{
javax.swing.SwingUtilities.invokeLater (new Runnable ()
{
public void run ()
{
JFrame frame=new JFrame();
frame.getContentPane().add(new Panel(new
Cubic(50,150,100,25,300,275,350,150)));
frame.setBounds(100,100,450,350);
frame.setVisible(true);
}
});
}
static class Panel extends JPanel
{
CubicCurve2D c1;
CubicCurve2D c2;
CubicCurve2D c3;
Panel(Cubic cubic)
{
super();
setBounds(0,0,400,300);
c1=new
CubicCurve2D.Double(cubic.p1.x,cubic.p1.y,cubic.p2.x,cubic.p2.y,cubic.p3.x,cubic.p3.y,cubic.p4.x,cubic.p4.y);
Cubic sub1=new Cubic();
cubic.subdivide(0.80,sub1,null);
c2=new
CubicCurve2D.Double(sub1.p1.x,sub1.p1.y,sub1.p2.x,sub1.p2.y,sub1.p3.x,sub1.p3.y,sub1.p4.x,sub1.p4.y);
Cubic sub2=new Cubic();
cubic.subdivide(0.30,sub2,null);
c3=new
CubicCurve2D.Double(sub2.p1.x,sub2.p1.y,sub2.p2.x,sub2.p2.y,sub2.p3.x,sub2.p3.y,sub2.p4.x,sub2.p4.y);
Cubic sub3=new Cubic();
cubic.subdivide(sub3,null);
}
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2=(Graphics2D)g;
g2.setStroke(new BasicStroke(3));
g2.setColor(Color.RED);
g2.draw(c1);
g2.setColor(Color.BLUE);
g2.draw(c2);
g2.setColor(Color.GREEN);
g2.draw(c3);
}
}
---------------- Cut Here
-------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]