My understanding of a fillet curve is that given three points where the middle point is associated with a radius, one can draw a curve from the two extreme points using a circle defined by the radius.
Is there support for this in WPF or would I have to implement it myself?
The answer is yes and no.
NO: There is no native function DrawFilletCurve(p1, p2, p3);
Yes: You can draw anything you want with Path. There is native support for cubic and quadratic Bezier curves.
You may also find something helpful in Live Geometry project, from MS ace Kirill Osenkov.
Related
I have some code that draws a cube. I've managed to rotate the cube using glRotatef but I need to be able to rotate the cube using only matrix multiplication. I know what matrices to use but I'm not sure how to apply them to the vertices of the cube. Is there a way to pass a vector to glVertex3f? Or a way to pass an array of vertices?
I agree completely with Drew's answer. However, I figured I'd point you in the direction of a nicely-written tutorial series that shows these concepts in action:
http://en.wikibooks.org/wiki/OpenGL_Programming
Start with the first 3 tutorials to learn shader basics, and then the 4th and 5th tutorials dive into rotation with triangles and cubes. Also, the examples use FreeGLUT, which is a framework that allows you to easily interact with your code using key presses, mouse movements, mouse presses, and more.
The OpenGL functions you're using are for immediate-mode rendering, and the vertex transformations are done within OpenGL. If you want to manually transform the vertices outside of OpenGL, you'll have to either implement matrix * vector multiplication, or use a library that does this for you.
As a side note, if you're just interested in rotation, you may find Rodrigues' rotation formula easier to implement than general matrix transformation.
In photoshop we can create bezier curve with pen tool,when we editing the completed curve,we can add point on the curve, in blend the same.
Now I have create a bezier path with wpf,how can I add point on it ,the special problem is I can't compute the control point of the new point.
Please help me, thank you.
what photoshop does is not "adding a control point", because that would raise the curve's order and change the curvature; instead, it splits the cubic curve into two cubic curves C1 and C2, with the endpoint of C1 and the startpoint of C2 are the same coordinate.
If WPF doesn't have curve splitting built into the API, then you might need to implement curve splitting yourself. It's pretty straight forward; for the DIY explanation, see http://pomax.github.io/bezierinfo/#splitting
The only challenge is to find the "t" value for the coordinate where you clicked, the simplest solution for that being to just generate the curve from t=0:1 in 1/100 or 1/1000 steps, and recording the x/y coordinate at each t value. That gives you a lookup table for instant lookup when you need to split the curve.
So I've read a lot about nurbs recently and completely understand nurbs curves ( even wrote a small library for it ). But I'm having some problem with surfaces. I can see that I need two sets of control points. My problem is that what the difference between points in these two sets is?
Can anybody briefly explain it or give me some link that does?
I think my favorite way of understanding NURBS surfaces (if you already understand NURBS curves) is beads on a wire.
So, let's look at the much simpler example of a Bezier surface (I assume if you understand NURBS curves you understand Bezier curves).
A cubic Bezier curve has 4 control points. Imagine a Bezier curve which is just a smooth horizontal curve. You can compute any point on that curve given a parameter value (usually this is called t).. just plug t into the parametric equation of the curve, and a point is produced.
Now imagine you have 4 horizontal Bezier curves, each one is above the other. If you plug the same parameter value into all 4 curves, you get 4 points, one for each curve. Those are the beads on the wires. Let's call the parameter value for the horizontal curves 's'.
Take those 4 "bead" points and treat them as the control points of a vertical curve. Evaluate that curve at another parameter value (this one we'll call 't', like usual) and it will give you a point. That point is on the surface. Specifically, that's the point P(s,t).
So, given a 4x4 grid of control points, you can use beads on a wire to compute points on the surface. As s changes, the beads sweep out different curves along the wire.. the set of all those curves is the surface.
You can do the exact same thing with Nurbs curves.. you just need a knot vector for s, another knot vector for t, and a grid of control points.
For a NURBS surface, you dont need two sets of control points, you need a 2 dimensional grid or mesh of control points. This mesh will have n rows and m columns, and each point in the mesh will have an x, y and z co-ordinate as well as a w value, the NURBS weight for that point.
Im trying to triangulate a polygon for use in a 3d model. When i try using the ear method on a polygon with points as dotted below, i get triangles where the red lines are. Since there are no other points inside these triangles this is probably correct. But i want it to triangulate the area inside the black lines only. Anyone know of any algorithms that will do this?
There are many algorithms to triangulate a polygon that do not need partitioning into monotone polygons first. One is described in my textbook Computational Geometry in C, which has code associated with it that can be freely downloaded from that link (in C or in Java).
You must first have the points in order corresponding to a boundary traversal. My code assumes counterclockwise, but of course that is easy to change. See also the Wikipedia article. Perhaps that is your problem, that you don't have the boundary points consistently organized?
The usual approach would be to split your simple polygon into monotone polygon using trapezoid decomposition and then triangulate the monotone polygons.
The first part can be achieved with a sweep line algorithm. And speed-ups are possible with the right data-structure (e.g. doubly connected edge list). The best description of this, that I know, can be found in Computational Geometry. This and this also seem helpful.
Wikipedia suggest that you break the polygon up into monotone polygons. You check that the polygon is not concave by simply checking for all angles being less than 180 degrees - any corners which has a angle of over 180 is concave, and you need to break it at that corner.
If you can use C++, you can use CGAL and in particular the example given here that can triangulate a set of non-intersected polygons. This example works only if you already know the black segments.
You need to use the EarClipping algorithm, not the Delaunay. See the following white paper: http://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf
I'm writting small application to draw diagrams and I need to find points to draw bezier curve between two elements.
Is there any efficient and simple way to calculate bending points ??
To better visualize my problem please take a look at this picture
As You can see I have two rectangles which I want to connect with bezier curve. It is obvious that I have two anchor points, but how can I calculate correctly bending points so that this line would look like at the picture.
On each end of the curve imagine a line perpendicular to the border through the anchor point.
The curve points should be on that line. The farther away from the border these points lie the more vertical the center area of the curve is.
(I hope this is clear, it's at the limit of my english abilities)