Inkscape: make two segments of the same path parallel or perpendicular - inkscape

Is there a command to make to make two segments of the same path parallel or perpendicular ?

I think the fastest and most universal way to achieve that would be by using a guide line.
Drag one out of the ruler, snap its origin to the end of one of the path segments that is meant to stay in place, then hold Shift and rotate the guide, until it snaps with the other end of the segment that is fine.
Then move the guide to the second segment, and snap the node that is 'off' to the guide.
Edit: for perpendicular, double-click on the guide after it has the correct slope for the first segment, then check the 'relative' box and add 90°.

Related

Project a line segment onto a mesh

What are the graphic/mathematical algorithms I have to look for in order to achieve the red line in the following image?
Explaining it better: I need to plot two points on the mesh and then generate a straight line segment from one point to the next. This line segment would be formed by new vertices created on every single edge in its way.
I'm currently working with CGAL and Libigl, but none of them seem to have the solution. I have tried CGAL::Surface_mesh_shortest_path but it adds too much overhead (code runs very slowly) and the line would not be guaranteed to be straight depending on the mesh deformation.
Ignoring whatever you mean as "straight", here is one simple algorithm I can think of that would produce images to the one similar shown in the question. There is no guarantee of what is produced being the shortest path. I'm just spitballing here with no knowledge on the topic, there are probably better ways.
Pick 4 variables:
The starting point
The ending point
The line's normal
A marching constant
Let's calculate a few constants from the variables:
Direction = ending point - starting point
Increment vector = normalize(Direction) * marching constant.
Begin from the starting point and march towards your ending point by some constant, checking above and below your current position for where you are on the mesh. You use the line's normal to understand the "up" and "down" directions in order to perform intersection tests.
On each intersection test, if you do not intersect for both the up and down directions, then the normal you chose will not work for the given two points and mesh, and you'll have to try a different normal. If you do end up intersecting from one of the directions, you will need to add 2 points to your final line: a point on the calculated direction line closest to the start that lies on the triangle, and a point on the calculated direction line farthest from the start that lies on the triangle. If there's both an intersection on the up and down directions, choose the up direction to work with.

Determine Orientation of a Sketched Arrow with OpenCV

I've got a bunch of arrow sketches and I want to determine their orientation, the starting point coordinates, and the ending point coordinates.
I'm using goodFeaturesToTrack but I'm really clueless as to what to do next.
This is what I've got
There is no restriction on the shape of the arrows, they can be as windy as you want them or they could be composed of straight lines and right angles.
I'd really appreciate any ideas because I really am lost. The project is about transforming a sketch of an Finite State Machine into a VHDL code and I've got the circles and characters covered so this is the last component but I have no idea how to approach the problem.
Instead of using goodFeaturesToTrack you can use HoughLines which will give you all lines in an image so I suggest that you do some segmentation first to get each arrow separately. HoughLines gives you all lines in polar coordinates which is perfect for you case as you can know the orientation of the lines. You can read more here: https://docs.opencv.org/3.4.0/d9/db0/tutorial_hough_lines.html
For straight lines your task is easy you need to find 3 line segments that intersect in one point (http://answers.opencv.org/question/92164/how-to-find-coordinates-of-intersection-of-lines-after-using-houghlines/). This will be the end point of your arrow, you can find the start point using the equation of the middle line.
For curved lines, it is a bit more tricky as you may get several hough lines for the curved segment or none at all. So in this case I suggest you get the intersection of the the 2 lines as your end point and then use goodFeaturesToTrack then starting from the closest point to your end point start moving to the next closer until you reach the end and pick that as the starting point.
I do not know if this would be the best solution and I did not try it myself but I hope it helps you or give you some direction.

C++ How to calculate an arc between two 3D points

I read through the forum and as I am sure this question has been asked before, but I couldn't really find what I was looking for.
My problem is the following:
I have an AI-Character moving along a spline. Should that path be blocked, the character should move in an arc around it and then continue on it's path.
For arguments sake lets assume that the spline has a length of 7000 units.
Therefore, I have two 3D (x,y,z) vectors. The first vector is the current position of the AI-bot and the second vector the position past the obstacle. For the time being lets just say: current spline position + 400 units; later on I could do a line trace to get the dimension of the obstacle etc. but for now I don't care about it.
Now I would like to compute an alternative path to avoid aforementioned obstacle - hence compute the arc between these two points - How do I do this?
I am really terrible at maths but looked at projectile trajectory because I thought that it would be sort of the same, just was unable to really understand it :<
It doesn't have to be an arc. You can solve this problem recursively in a very simple way.
Consider you're at position A, and the obstacle is at position B. You can do the following moves:
From current position to A+V(B[x]+height(B),0,0)
From current position to A+V(0,B[y]+width(B),0)
From current position to A+V(B[x]-height(B),0,0)
where V is a vector with components V(x,y,z), width(B) is the width of the obstacle and B[x] is the x component of the position of B. This way you moved around it along a rectangle. You can now smoothen the path by subdividing that rectangle in halves. 3 subdivisions are enough to make this smooth enough. To subdivide, take the middle point the first path, and draw a line to the middle of the second path. The same you do from the second path to the third one, and now your rectangle becomes an octagon. If that's not smooth enough, do a few more steps. This will create a new spline that you can use.
I would look at a combination of splines and the EQS system. The spline defines the ideal path to follow. The EQS system finds locations near or on the path, while still doing obstacle avoidance. EQS can return all valid destinations so you can manually order them by custom critera.
Actors set on a spline do work, but there's a whole bunch o' mess when making them stop following a spline, creating a new one at the correct point, attaching the actor the new spline, and so on.
I arrived at this conclusion yesterday after exactly going the messy way of adding spline points etc. The only problem i see is that I find the EQS system very difficult to understand. Not following the examples as such, but modifying it in the way I need it. Lets see, i keep you posted.

Creating and Saving an image in C++ VS

My question in brief:
I have many coordinates points(x,y) which needs to be drawn and saved as a picture in a folder. I need to write codes using C++.
Detailed Explanation:
Let's say i have n coordinate points(x ,y). I have two functions namely the "jump" and the "mark".
The function call would be in this sequence always:
jump(x,y)
mark(x,y)
jump(x,y)
mark(x,y)
..............this sequence happens till all coordinate points are considered finished.
1)The first Jump function will point to the current coordinate position/start position.
2)All mark functions would draw a continuous line from the previous jump function coordinates to the the coordinates it received.
3)Rest of the jump functions(except the first jump function) would draw a dotted line/dashed line from the previous mark coordinates till the coordinates it received. So this line would tell us from where did the jump function jumped to draw the next mark line(Refer attached Picture for better clarity)
How do i implement it?
Any graphic libraries in C++ available to perform simple plotting and saving of an image like i wanted?
I read about few graphics libraries like SDL, OpenCV, OpenGL, PNGWriter.
But not sure what and how to use.
I have shown a small example of what i wanted to do, which is attached as an image.
Click here for the Image
I work with opencv, but it not support dash line while in this link there is a guide for dash line in opencv dotted line and dotted and dashed rectangle in OpenCV, for your program, you can create an white image with desired size and draw line by charactrize the start and end point coordinate and apply function:
Line draw
You can store the latest point's coordinate in a Point variable....
I suggest you use the Allegro, it's much more simple and lighter than OpenCV. I believe it will be more agile for this.
This link you can find the binaries (~44MB) for VS (select the appropriate for your vesrion).
Extract the zip file. You will see the include\, lib\ and bin\ directories. Link them appropriately in Visual Studio (this is the complete tutorial).
Here you will have the basics of reading, writing and displaying an image (Bitmaps).
I think the function al_draw_line() will help you on this specific task.

Fit a curve in angle line?

I have two lines that start and end at random locations on a screen and create an angle. I then have an object follow these two lines. However at the intersection between the first and second line, the object rapidly rotates to go down the second line. And I don't want this.
So what I want to do is be able to create a curved version of this line that would have a more of a U at the intersection rather then a hard turn. I looked into curve fitting papers and can't seem to find that that would allow me to create a U out of a V.
Sorry for the terrible images... I want to take the one of the left, and generate the one on the right (same start, end, and intersection points). Another example, http://en.wikipedia.org/wiki/Curve_fitting
Any ideas?
You should take a look at http://en.wikipedia.org/wiki/Bezier_curve
Or just http://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Bezier_2_big.gif/240px-Bezier_2_big.gif
If the coordinates of the start/end points of the two lines are known, you can simply calculate an bezier curve follows the methods in the link above.
If not (for example with an bitmap like what you post), you can do Hough Transform first to extract the coordinates