How to know if two lines intersects in ZedGraph? - intersection

I am using ZedGraph to draw graphs in C#. I have been asked to draw a parabole and a "normal" line in the same graph, and I need to know programatically if the parabole and the line intersect at any point (actually, I have to know that AND if one line is close enough from the other).
Is there a way to know that in ZedGraph?
Thank you very much in advance.

Related

How can one make arrows as in the figure below?

I am very interested in war history and would like to make operation maps by myself. Really appreciate if anyone know how to draw attack arrows as in the figure below. Would be great if a GIS software can do that. Thank you very much.
GIS Programs can do this. I'm unclear if you have pre-existing line data or not, but regardless you can add an arrowhead in 'Symbology'.
If you do not have lines showing the movement you can create them in ArcGIS with 'Create Features'. You will draw where you want the lines to be and can add the arrowhead in the symbology afterwards.
See this post:
https://community.esri.com/t5/arcgis-pro-questions/show-direction-of-route-with-arrow-symbol-in/td-p/613399

Polygonal Search

I have read several of the posts concerning Polygonal Search, but they are all about fixing or updating the programs. I am just wondering how it works. If there is a way I can get something like pseudo code of it or an explanation of how a shape captures the data points.
To further specify my goal, I am trying to make a constant square that will be held over a map (such as google maps), but the map can move around behind the square, however, the square will continue to report whatever cities lie within its bounds. [I will eventually proceed to building it, I just need some guidance]
Thank you.
There is an open-source library which has a function to check if two shapes overlap. You can check source code:
http://turfjs.org/static/docs/module-turf_inside.html
If you look for theory behind it check Hyperplane separation theorem

Find all points along a path AS3

Basically, I want to randomly add a movie clip to any point along a bezier curve. Is there a way to find all points along a path? Or maybe there's a way to find the equation (it's a quadratic curve)? If all else fails, is there a way to find the points along a straight line (that isn't perfectly horizontal or vertical)?
If you are using the pen tool, this is creating a Shape. You can access the path of this shape by reading the result from Shape.graphics.readGraphicsData()
See the reference for readGraphicsData.

Smooth canvas sketching without clearing (redraw)

I'm trying to find a way to smooth out the points for sketching to get a cleaner result. I've found this example, and the result looks quite good
I've found some ways that use cubic curves to smooth out the edginess, but all of them requires the line to be redrawn from the beginning since they work with multiple points.
My initial idea was to "draw" the final "part" of the line when there are enough points to calculate the bezier (simply 2 frames after points are taken) to overcome the need of "redrawing" every time.
Any ideas/workarounds about this will be appreciated.
Thanks!

Converting Pixels to Bezier Curves in Actionscript 3

Ok, so I'll try to be as descriptive as possible.
I'm working on a project for a client that requires a jibjab-style masking feature of an uploaded image.
I would like to be able to generate a database-storable object that contains anchor/control positions of a bezier shape, so I can pull it out later and re-mask the object. This all is pretty easy to do, except for one catch : I need to create the bezier object from a user-drawn outline.
So far, here's how I imagine the process going:
on mouse down, create a new sprite, beginFill, and moveTo mouse position.
on mouse move, lineTo an XY coordinate.
on mouse up, endFill.
This all works just great. I could just store the info here, but I would be looking at a GIGANTIC object full of tons of pretty useless x/y coordinates, and no way to really make fine-tuning changes outside of putting handles on every pixel. (I may as well give the end user a pencil tool...)
Here's what I'm thinking as far as bezier curve calculation goes :
1: Figure out when I need to start a new curve, and track the xy of the pixel on this interval. I'm imagining this being just a pixel count, maybe just increment a count variable per mouse move and make a new one every x pixels. The issue here is some curves would be inaccurate, and others unnecessary, but I really just need a general area, not an exact representation, so it could work. I'd be happier with something a little smarter though.
2: take each new x/y, store it as an anchor, and figure out where a control would go to make the line curve between this and the last anchor. this is where I get really hung up. I'm sure someone has done this in flash, but no amount of googling can seem to help me out with the way to get this done. I've done a lot of sketching and what little math I can wrap my brain around, but can't seem to figure out a way of converting pixels to beziers.
Is this possible? All I really need is something that will get close to the same shape. I'm thinking about maybe only placing anchors when the angle of the next pixel is beyond 180 degrees in relation to the current line or something, and just grabbing the edge of the arc between these changes, but no matter how hard I try, I can't seem to figure out how to get this working!
Thanks for your help, I'll be sure to post my progress here as I go, I think this could be really useful in many applications, as long as it's actually feasible...
Jesse
It sounds like a lot of work to turn pixels into Bezier curves. You could try using something like the Linear least squares algorithm. http://en.wikipedia.org/wiki/Linear_least_squares
A different tact, could you have your users draw vector graphics instead? That way you can just store the shapes in the database.
Another cool method of converting raster to vector would be something like this iterative program: http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/
Good luck
In my answer to this question I discuss using autotrace to convert bitmaps to beziers. I recommend passing your user drawing through this program on the server. Autotrace does a fantastic job of tracing and simplifying so there is no need to try and reinvent the wheel here.
Thanks for the answers, although I guess I probably should be more specific about the application, I'm really only needing an outline for a mask, so converting images to vectors or polygons, despite how cool that is, doesn't really fix my issue. The linear least squares algorithm is mega cool, I think this might be closer to what I'm looking for.
I have a basic workaround going right now, I'm just counting mouse moves, then every X (playing with it to get most desirable curve) moves, I grab the xy position. then, I take every other stored xy, and turn it into an anchor, the remaining xys are turned into controls. This is producing somewhat desirable results, but has some minor issues, in that the speed at which the mask is drawn effects the number of handles, and it's really just getting a general area, not a precise fit.
Interestingly, users seem to draw slower for more precise shapes, so this solution works a lot better than I had imagined, but it's not as nice as it could be. This will work for the client, so although there's no reason to pursue it further, I like learning new things, and will spend some off the clock time looking into linear least equations and seeing if I can drum up a class that will do these computations for me. If anyone runs across some AS3 code for this type of thing, or would like some of mine, let me know, this is an interesting puzzle.