From: Christian H. D. <da...@da...> - 2001-12-12 13:12:58
|
Thanks for the feedback. Let me go through your comments "Larry W. Virden" wrote: > From: Christian Heide Damm <da...@id...> > > # geometry.tcl -- > > # See the file "license.terms" for information on usage and redistribution > > # of this file, and for a DISCLAIMER OF ALL WARRANTIES. > > Remember that the current Tcllib policy is for code included to be covered > in a BSD or very VERY similar license... That's ok. > > # ::math::geometry::calculateDistanceToMultiline > > # > > # Calculate the distance between p and multiline. > > # > > # Arguments: > > # p a point (x,y) > > # multiline a list of points (x,y) constituting a line > > How many points in multiline? How many lines (multiline sounds like > multiple lines...) I know 'multiline' is a bad name. What it meant is a line with bends. For example, a multiline could have the coordinates 10 10 20 20 20 0 and this would be a line starting in 10,10 going north-east to 20,20 and then continuing south to 20,0. Does anybody have a better name? There are basically three types of lines: * line segment: a _finite_ line between two points A and B * line: an _infinite_ line going through two points A and B * multiline: a sequence of connected line segments > > # Results: > > # dist the smallest distance between p and any point > > # on the multiline > > What is dist? a single floating point value? Yes, I'll clarify that in the code. > > proc ::math::geometry::calculateDistanceToMultiline {p multiline} { > > ... > > } > > > > # ::math::geometry::findClosestPointOnMultiline > > # > > # Return the point on $multiLine which is closest to $p. > > # > > # Arguments: > > # p a point (x,y) > > # multiline a list of points (x,y) constituting a line > > # > > # Results: > > # q the point on the multiline that has the smallest > > # distance to p > > # > > I assume that q is also an x and y? Is it one of the points listed in > multiline, or a point calculated to exist on the line that includes the > points of multiline. If you draw q in a coordinate system, and then draw the multiline, then the multiline will "hide" q. For example, q could be 15,15 in the example above, since 15,15 is on the line segment between 10,10 and 20,20. > > # ::math::geometry::calculateDistanceToLineSegmentImpl > > # > > # PRIVATE FUNCTION USED BY OTHER FUNCTIONS. > > So this function will not be one that developers would be needing to call > in general? No, it contains code that is shared by 2 or more other functions in the package. > > # ::math::geometry::calculateDistanceToLine > > # > > # Calculate the distance between C and the infinite line > > # that goes through A and B. > > How is this different than the first distance calculating? calculateDistanceToLineSegment and calculateDistanceToLine are different, because a line segment is finite. The distance between (0,0) and the "line segment" (10,10)->(20,20) is sqrt(200). The distance between (0,0) and the "line" (10,10)->(20,20) is 0 (because the line is infinite and goes through (0,0)). > > # ::math::geometry::length > > # > > # Find the length of the line (x1,y1),(x2,y2),...,(xn,yn). > > I assume that this is "find the length of the line segment > from x1,y1 -> xn,yn" ? No, it is the sum of the lengths of the individual line segments. > > # ::math::geometry::angle > > # > > # Calculates angle from the horizon to the line (x1,y1)->(x2,y2). > > # > > # Arguments: > > # x1,y1,x2,y2 the line > > # > > # Results: > > # angle the angle between the line (0,0)->(1,0) and (x1,y1)->(x2,y2). > > # angle is in 360-degrees going counter-clockwise > > # > > Is angle returned in degrees? radians? some other unit? This time, the documentation is precise enough: it is returned in degrees. > > # ::math::geometry::findLineSegmentIntersection > > # > > # Returns the point where the two line segments intersect. > > # Note: may also return "coincident" and "none". > > # > > # Arguments: > > # line1 the first line segment > > # line2 the second line segment > > What are these arguments? 2 or more x,y pairs? Yes. > > # Results: > > # p the point where line1 and line2 intersect. > > So p's value is a list, consisting either of one of two words or an x,y pair? p can be * none * coincident * 10 20 (if the intersection point is 10,20) > > # ::math::geometry::findLineIntersection {line1 line2} > > # > > # Returns the point where the two lines intersect. > > # Note: may also return "coincident" and "none". > > # > > # Arguments: > > # line1 the first line > > # line2 the second line > > What are these arguments? 2 or more x,y pairs? A line is always defined by exactly two points. > > unsure_about_these { > > unsure in what way - whether you will do them? whether they belong here? > whether these are the right names? whether these are the right interfaces? We have already done them. First of all, I'm not sure that they are general enough to be in a tcllib module. The next problem is the names and interfaces, but I'll worry about that when we have decided whether they should be in the module. Many of your questions are related to * the difference between line, line segment, and multiline * the types of parameters and return values How about if I put something at the top of the file about lines, line segments, and multilines, and that they are defined by so many points. Then I can just write # Arguments: # line1 the first line # line2 the second line and everyone will know that I'm talking about an infinite line, and that line1 is a list of 4 numbers? The second problem: I could put the type float/int at all relevant places, or I could again just write at the top of the file that everything related to coordinates and distances are floating point values? Christian |