Now i'm analyzing polygon example in boost geometry
http://geometrylibrary.geodan.nl/03_polygon_example_8cpp-example.html
After draw a few lines, if I want to get cross point between polygon border line and normal lines, what function should I use??
Click to See a sample image what i want
I want to know those red circle point coordinate. I don't know that a way of combination of line points i inserted and the polygon
Would the function documented here (get_intersection_points) help? You could intersect your line segment with the shapes you want to check.
Related
Looking for a solution to get the grid lines inside or over the polar area points.
Like the image attached.
I found the code which draws the gridLines and the one draws the point.
I also see it's possible to pass a creationPattern() as background.
But I don't know how to get them working together.
Maybe a solution can be simply show the gridLines over the points and not behind.
There a is an ellipse on the picture,just as following.
I have got the points of the contour by using opencv. But you can see the pictrue,because the resolution is low, there is a straight line on the contour.How can i fit it into curve like the blue line?
One Of the method to solve your problem is to vectorize your shape (moving from simple intensity space to vectors space).
I am not aware of the state-of-art in this field. However, from school information, I can suggest this solution.
Bezier curves, you can try to model your shape using simple bezier curve.This is not a hard operation you can google for dozen of them. Then, you can resizing it as much as you want after that you may render it to simple image.
Be aware that you may also Splines instead of Bezier.
Another method would be more simple but less efficient. Since you mentioned OpenCV, you can apply the cv::fitEllipse on the points. Be aware that this will return a RotatedRect which contains the ellipse. You can infer your ellipse simply like this:
Center = Center of RotatedRect.
Longest Radius = The Line which pass from the center and intersect with the two small sides of the RotatedRect.
Smallest Radius = The Line which pass from the center and intersect with the two long sides of the RotatedRect.
After you got your Ellipse Parameters, You can resize it as you want then just repaint it in the size you want using cv::ellipse.
I know that this is a pseudo answer. However, I think every thing is easy to apply. If you faced any problem implementing it, just give me a comment.
I am trying to write a small drawing program with Livecode, that will show the length of the drawn line over the line so it is available for editing, I also need to display the angles of the polygon for editing. The user should be able to select one section of the polygon by clicking on the dimension. This will load the length of the line into the field on the right for editing. Once the correct number is entered the drawing will redraw itself. (I can probably figure this part out using the "points" of the polygon) I have included a screen shot of what the program should look like. I was hoping that it would display these figures as the image was being drawn by the user. I am sorry I have not included any code, however I don't even know where to start. I have written several programs involving databases, but this is my first attempting to use drawings. Thanks in advance for any advice!! http://i.stack.imgur.com/gfKS9.jpg
To get the angle you can use some trigonometry. if you have two points (which you can get by using
the points of graphic "myPolygon"
Then you get one point per line. If you want to calculate the angle between two points you can use some trigonometry. If you have a point x1, y1 and another point x2,y2 you get the angle by using
put atan2(y2-y1, x2-x1) into tRad
The angle will be in radians from -pi to +pi so you need to convert it to degrees if you want more "regular" degrees:
put tRad*180/pi into tDeg
The angle you get is according to the x-y coordinate system. So if you want the angle between to lines you need to do two calculations and add the angles.
You can't change the size of a single segment but all polygon.
To change the size of the line...
set the linesize of graphic "polygon" to 4
Paolo
I'm creating a comic book editor. I want to be able to use some fairly complex customisable shapes for the speech balloons.
I can draw the tail and then draw a balloon but that means I have the outline inside the shape and I want it only around the edge.
I assumed QPainterPath::simplified() would solve the problem but it doesn't seem to do anything.
At the moment my best idea is to draw a shape with a thick outline and then draw it again with no outline but I don't think that will work for "zero width" outlines.
I can think of two possible solutions here:
Draw both the "tail" and the main "balloon" as a single shape. In this case, you'd simply draw a single shape with a single outline and a single fill.
Draw them separately, but twice. Draw an "expanded" version of the shapes in black first, and then draw the "normal" version of the shapes in white over the top of it. You wouldn't draw any "lines" at all - the "expanded" version of the fill would serve the same purpose.
The first method would allow alternative line styles to be used (dotted or wiggly lines), but the latter would allow the "outline" to be slightly offset, so that it appeared thicker around some edges and thinner around others.
It turns out QPainterPath::simplified() does work. It depends on whether I draw clockwise or anti-clockwise (I believe it works when drawn clockwise), which I presume is down to how Qt's Winding Fill works.
// create a path representing the bubble and its "tail"
QPainterPath tail = tail.shape();
tail.addPath(bubble.shape());
tail.setFillRule(Qt::WindingFill);
painter->drawPath(tail.simplified);
I'm trying to program a brush stroke/drawing application using OpenGL within Openframeworks. For now I'm just trying to create squiggly lines that follow your mouse.
I've started by using ofpolyline but I have just managed to create a straight line that follows my mouse. I would really appreciate some pseudo code or something to point me in the right direction.
start. set (mouseX,mouseY);
end.set(mouseX,mouseY);
ofPolyline myline;
myline.addVertex(start.x,start.y);
myline.curveTo(end.x,end.y);
myline.bezierTo(mouseX,mouseY, mouseX,mouseY,mouseX, mouseY);
myline.addVertex(end.x,end.y);
myline.draw();
A Bezier curve with two vertices is always just a straight line segment. You need to add more vertices/control points to get non-degenerate (round) curves. So you could store the last mouse position somewhere, and add a new vertex when the mouse was moved by a certain amount (eg 20 pixels). Or add a vertex when the user clicks. However, if you always just call bezierTo(x,y,x,y,x,y), you will still only get straight lines. You need to offset the two control points from (x,y) to get round curves.