World: r3wp
[View] discuss view related issues
older newer | first last |
Steeve 24-May-2009 [8904] | a is a value between 0,1 |
Maxim 24-May-2009 [8905x3] | I know bezier really is just an iterated break up of an algorythm between control points.. I could implement the math, but if you've got some stuff all done ;-) |
all the algorythms are available on the web via siggraph and other sources, but coding that stuff usually isn't very fun. | |
I was asking, cause I saw a demo once of someone rebuilding the AGG spline manually right over the AGG one.. so some code definitely exists. | |
Steeve 24-May-2009 [8908x2] | no, i use it to interpolate colors, not coordinates, so it is no use as it is in my script. But it's easy to figure how to interpolate coordinates instead of colors gradiants, i gues... |
Giving 2 points as input , i can write it if you want, but give me the paremeters you want and the result expected (an image, a block of coordinates ?). Give the specs | |
Maxim 24-May-2009 [8910] | for linear interpolation its pretty easy. this is the complicated use... give me the (x.y) at length z of (bezier, nurbs, quadratic, etc) spline defined by points p1, p2, p3, p4, pn |
Reichart 24-May-2009 [8911] | We wrote our own spline (arc function for a Paint program we did). DPaint had this, which implies John's RPaint has this code too, no? |
Steeve 24-May-2009 [8912x2] | ho i see, your input is a length and you want the coordinates in return ? |
tricky need | |
Reichart 24-May-2009 [8914x2] | The nice thing is that it works backwards, which is, you give it XY, and a control point, and it draws thorugh the control point. |
Of note, if you want another way to think of an arc. Think of drawing 3 points A B C (C is the "pull") Now, you have what looks like a triangle. If you make a tic halfway between A and C, and B and C, and draw a line been these tics, then keep doing this, you will eventually make an Arc. The last tic is where your Mouse cursor would end up. That is why Arc in RPaint is "backwards". Cool, eh? | |
Steeve 24-May-2009 [8916] | Wow, i understood nothing... |
Reichart 24-May-2009 [8917] | What do you mean? |
Maxim 24-May-2009 [8918] | reichart that is the exact bezier algorythm. |
Reichart 24-May-2009 [8919] | Yup. |
Maxim 24-May-2009 [8920x2] | ok, so I should bother john for his function... he probably profiled it and such... I'm just lazy. |
now I have a real math problem... I didn't even find a direct solution on wolfram mathematica site. do you know of an algorythm (expressed in code, not in math) that can give me the ellipse with two supplied coordinates. center and one point which touches the ellipse? | |
Reichart 24-May-2009 [8922x3] | Steeve, was there something you wanted described? |
Maxim, probably not, since you need to first find an example in a real program that uses that UI. Perhaps GIMP though? | |
My paint program let you draw a start point, and drag a line in some direction, then show an ellipse on that "angle". Then, you could size the width and length, in real time, then when you released the mouse it snapped perfect....it was VERY fast, and very cool. | |
Maxim 24-May-2009 [8925] | some graphic app I'm writting ;-) does the ellipse dragging in real time, but uses x-radius and y-radius which is snapped to the edge of the ellipse... I just prefer single point editing... but for that to be intuitive, the point really has to be exactly on the ellipse... and since ellipse have 2 center points... ellipse seem to be very complex challenge, by what I've read, there isn't even today an exact method to calculate the arclen of an ellipse... only very close approximations! |
Reichart 24-May-2009 [8926x3] | Yup, all circles (ellipses) are doe with an error correction routine. |
We too had to correct "to a pixel" | |
How will you set the "width" of your ellipse? | |
Maxim 24-May-2009 [8929x4] | basically, two points reside on the major and minor axis and a reference center is used. if rotation is needed, I can easily calculate the vector from any of the axis to the center. |
but right now the rotation is locked, cause I'm not sure its a good thing to rotate the ellipse for this specific application. | |
but the powerfull thing, is that you can drag the ellipse itself, by clicking on any part of the line itself, no cvs to drag the shape. :-) | |
and just hovering over the line (the arc) the cvs appear, so they don't clutter the drawing while you're editing other parts of it. | |
Geomol 25-May-2009 [8933] | A REBOL Bezier algorithm: do http://www.fys.ku.dk/~niclasen/rebol/fysik/bezier.r Move the points around with the mouse. |
Maxim 25-May-2009 [8934x4] | that's the demo I was talking about ;-) |
so you don't mind if I use that code in my own projects? | |
first use will be to build a keyframe editor, which will be distributed with liquid-paint, with MIT license. | |
(for spline-based animation curves.) | |
Geomol 25-May-2009 [8938x2] | Use as you like. |
do you know of an algorythm (expressed in code, not in math) that can give me the ellipse with two supplied coordinates. center and one point which touches the ellipse? Isn't there an infinite number of ways, you can do that? | |
Maxim 25-May-2009 [8940x2] | thanks! for the spline code, with a few changes, one in three points should pass directly through the point and the two other points will be used as tangeants. |
its not really obvious... I'm not a math expert, even if I've done some pretty cool 3D engines (crowd simulation, for example) it takes me a lot of time to get the math part of things done when its question of doing math mix and match. | |
Geomol 25-May-2009 [8942] | Let's say, you have center and a point with same y-coordinate as center. So it's just horizontal out from the center. Now the ellipse can be any height, so you can make infinite many ellipses with those two points. |
Maxim 25-May-2009 [8943] | I did whole evening of research on the ellipse and didn't find a single exact procedure to do it... some math dr have done their thesis just on finding ways to calculate its arc len ! though I think its possible to resolve the two foci based on the angle and distance of the point we want to pass through the arc, all the math needed to get to the proper major and minor axis (eventually equating to what people call the x and y radius) is pretty intensive. |
Geomol 25-May-2009 [8944] | In DPaint (and Canvas RPaint), you specify center and corner of ellipse. It's then not rotated. After specifying size this way with two points, you can rotate it. |
Maxim 25-May-2009 [8945x2] | yes but the corner is not *ON* the line, its equal to the major and minor axis of the elipse. |
if I where to drag one of those points to an angle of 30 degres, I still want the arc to touch my point. | |
Geomol 25-May-2009 [8947] | Yup, but you can't make just one ellipse with center and point on the ellipse. |
Maxim 25-May-2009 [8948] | there is definitely a way to calculate it mathematically, but there are so many steps, I get lost in the procedure to get to it. |
Geomol 25-May-2009 [8949x2] | :-) Think of my example with center and point horizontal out from the center. What height should your ellipse be? |
The problem is not, that it's hard. It's impossible. | |
Maxim 25-May-2009 [8951] | in that case, its can be treated as a special case... like a like since one of the axis is = 0 just like the up vector of a 3d object cannot be (0,0,0) |
Geomol 25-May-2009 [8952] | Ah, I now think, I understand, what you want. It's like the arc drawing routine, where you want the point to be on the line. Same thing with ellipse. |
Maxim 25-May-2009 [8953] | but if x and y axis aren't = 0 then the angle of the point, can let you calculate the two foci, which are relation to x/y. |
older newer | first last |