Re: Feature freeze



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/

Attachment: gap_cleanup.diff.gz
Description: GNU Zip compressed data



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]