This is a multi-part message in MIME format. --------------030904090901040801020602 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi Lars, your edge detection code looks nice. There are a few weird things that happen when you slide objects over each other, but that may be inevitable since the only information available is the distance_to_point. But to create nice looking bond graphs in a snap, it works great with the flowchart - box object adjusted to have a center connection point. Diff included, if you want it. I did not number the center point connection #0 to avoid breaking existing box objects... Check the file out to make sure I did it correctly, if you want to incorporate it. I use it, and it seems to work fine. In the medium term, I will simply create something similar (with no outer connection points) in the bond graph library. About the ellipse: I tried out the math, and ran into things that would be messy to do (requiring polynomial root solvers). I found something on the web that confirms this (see below). Another way this could be done would be to approximate the ellipse by a polygon, and then take the min of the distances to the line segments. For a circle, however, calculating the distance is pretty easy: Determine the angle of the segment from the center of the circle to the point. Then find the point on the circle with that angle, and then calculate the distance between the points. >Probably useful. However, we still have to figure out what to do for arc, >zigzagline, polyline and bezier. > For polyline, it will be simple. calculate_gap_endpoints and calculate_object_edge will work. For arcs and bezier lines, there will be no code overlap, I think. The concept of fractional or proportional gap would require calculating bezier/arc length, and then not drawing the last 'x' units of the line. Impossible, I think, for bezier lines without a math engine running inside dia. For arcs, probably possible--but with new code. Is it worth it? >Look at todays anoncvs first, make a unidiff off of that. > > About the included patch: line_calculate_intersection_points is a separate function because it may be useful elsewhere. The same goes for calculate_gap_endpoints since it is a basic geometric transformation. I used it a lot when doing my example arrow code. Having gap as a separate structure makes the code easier to read, and it also made my example decoration code much cleaner. Did you try it out, or were you too busy working on the edge detection stuff? All of the (line->object_edge_start || line->object_edge_end || line->absolute_start_gap || line->absolute_end_gap || line->fractional_start_gap || line->fractional_end_gap) { stuff has been moved into line_calculate_visible_endpoints() and line_calculate_intersection_points(). This makes the rest of the code much more readable. These functions just copy their inputs to their outputs if the gap/edge variables are not set. This adds a couple of function calls--I don't know if you're a clock-cycle counter, or not. I prefer code that's easy to read. Tell me if this is a problem. Dave. -----------------MATH FORUM----------------------- I desire a method to find the (minimum) distance from a point to an ellipse (point and ellipse both in the same plane). The point may be inside or outside the ellipse. We have been trying to find the tangent line to the ellipse that is perpendicular to the line drawn from the point to the same tangent point. So far we have failed. Any thoughts you have on the subject would be appreciated. Chuck Ingrum Date: 05/20/97 at 08:40:03 From: Doctor Jerry Subject: Re: Distance from point to an ellipse Hi Chuck, The slope of the ellipse x^2/a^2+y^2/b^2 = 1 at the pt (x,y) is -b^2*x/(a^2*y). If (X,Y) is a point outside, then the slope of line from (X,Y) to a point (x,y) on the ellipse is (Y-y0)/(X-x0). As you suggested, you want to choose (x0,y0) such that the slope of the segment from (x0,y0) to (X,Y) is the negative reciprocal of the slope of the ellipse at (x0,y0). So: (Y-y0)/(X-x0) = a^2*y0/(b^2*x0) Regarding (X,Y) as given, another equation is: x0^2/a^2+y0^2/b^2 = 1 You must solve these two equations for x0 and y0 in terms of a, b, X, and Y. However, this is not so easy. You can solve the first equation for x0 in terms of y0. Substituting into the second equation and simplifying gives, after some effort, a fourth degree equation to solve for y0. One could apply Ferrari's method, which solves quartics exactly, but I think it would be a giant mess and probably would not simplify very much. So, my opinion is that though in specific cases a quick solution could be found, there is no convenient formula for the general case. -Doctor Jerry, The Math Forum Check out our web site! http://mathforum.org/dr.math/ --------------030904090901040801020602 Content-Type: application/x-gzip; name="gap_cleanup.diff.gz" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="gap_cleanup.diff.gz" H4sICCcG7j0AA2dhcF9jbGVhbnVwLmRpZmYA3Rtrb9s48nP9K2b3gJwdyY7lxklbo72mba4o 0E2CJPs4HBaCbNGJbhXJkOSkuW3++82QlERJpCy7/XB3QdvY5LxnOJwh2eFwCGEQsdFiFIf+ s1+ZDx/YAuAQnMNXh+NX4ylMxuNJz7IsCVeHcV5NJwLm7VsYHjr2EVj4r+PA27c96EH2uGI+ W0KaJetFBu5npHKRxCuWZAFLofp1hhhWHeOjt4I/exZAwrwQvHkah+uMuWnmJZl7463scoxF Po3MCuhl4i2yII68UIVXRkuMJ/jIf+tFRgkA4H0c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