JuliaGeometry / GeometryBasics.jl

Basic Geometry Types
MIT License
164 stars 54 forks source link

perspective #103

Open JeffreySarnoff opened 3 years ago

JeffreySarnoff commented 3 years ago

From a preliminary glance, the package has at its core the notion of a parameterized abstraction of Points where concrete points that share the same dimensionality and use the same numeric type for coordinates work with the same set of methods in the same computational manner.

Once one has constructible points of given dimension and coordinate type, the usual next geometric step uses an ordered pair of points to signify and represent a directed line segment. The direction is given by the order of the two points, where the first point determines the initial position from which directionality is taken in the direction of the second position. The pair of points capture an extent, which is given by the distance of their separation (conventionally determined using the 2-norm, where required or just helpful different metrics ought be available and customizable).

The first point of the pair has the role of root or origin for the finite directed segment. The second point of the pair has the role of delimiting extent and carrying the [first point relative] direction. The first point is as the feathers of an arrow's tail and the second point is as the point of an arrow's head.

Once one has constructable finite directed line segments, the usual next step is to introduce rays, rooted at the first point and directed through the second point and of unlimited extent. The direction of a ray is oriented along the direction attached with the ray's generative finite segment. There is an associated opposite segment which obtains by swapping the order of the first and second points. With this opposite segment there is constructable the opposite ray (opposite to the ray constructed from the original segment).

By combining, simply taking these two rays together, we have the information necessary to the construction of a line. The line remembers the finite line segment underneath its construction, and in that respect, lines have a mercurial quality. The line keeps all its abstract character and all of its specific aspects while the underlying segment may travel along the line in either the originally given direction or in the opposite direction.

As long the relative position (first, last) of the originating points is maintained, lines are usefully intrinsically oriented. For many uses, this intrinsic lineal orientation may be ignored. For constructive purposes and to obtain more robust and consistent numerics, this orientation is computationally helpful.

When constructing a triangle in a plane as the interior of three escribed lines, pairwise nonparallel and noncoincident, the triangle will be oriented in concert with circulation of the bounding line's connective direction. This does mean that if one of the three bounding lines is directionally discordant with the other two, its opposite must be used (and either explicitly or implicitly maintained within in the triangle's construct).

Given a finite line segment, we can obtain a third point, for simplicity and to make the calculations more obvious, we utilize the midpoint or some other easily obtained internal point of that segment. At that location it is important to be able to construct a fourth point that is not on the line segment yet is perpendicular to it with that perpendicular going through (emanating from) the third point.

In 2D space, place the fourth point on the side of the segment found by a quarter turn from the directed segment (like the minute hand of a clock is centered at the third point and 12 is located at the segment's arrow head, the segment's second point) counterclockwise. The turn is counterclockwise simply to conform to the usual 2D X, Y orientation; we find positive angles from 0..pi/2 by rotating about the origin from positive X toward positive Y. In 3D we follow the "right hand rule" and in higher dimensions we continue that pattern.

Back to 2D. We have located the half plane into which the fourth point goes and we have located the ray (half line, as it were) onto which the fourth point is placed [the perpendicular to the original segment at the midpoint, directed into the identified halfplane]. We have the first point of a segment (the midpoint) and we have a direction. All that remains is to associate an extent and then the fourth point is wholly constructable. Take half of the original segment's extent as the extent from the third to the fourth point. (The "other half" of the extent would be on the other side of the original segment, and that may come in handy .. so, we preserve it by only using half of that extent to position the fourth point.)

With the third and fourth points, we construct a finite directed line segment. Using the first, second and fourth points we may construct an oriented triangle where those points are the vertices and are ordered as given. Where an isosceles triangle is desired, place a fifth point in the direction of the new segment, locating it by using the same extent again. The construct the triangle from the first, second and fifth points.

That triangle, itself or a homeomorphism thereof, also gives the halfplane to which it associates (point1..point2 is the base delimiting the plane, the apex at point3 is the direction of cover). Just as we constructed the opposite associated with the original directed line segment, we can construct the opposite triangle and so obtain the opposite halfplane. By combining halfplanes, we obtain an entire plane.

This does generalize to 3D and 4D, and one may continue the patterning into higher dimensions (better than following a pattern without knowing why, adopting the relations of a more formal geometric algebra will keep our logic consistent, relationships intact, and results reproducible.) Geometric intrinsics and algebraic elaborations obtain.

juliohm commented 3 years ago

@JeffreySarnoff thank you for sharing your thoughts on line segments, rays, lines, and what it seems to be a recipe for the construction of simplices from a starting line segment. Do you have a question or suggestion of improvement? I didn't grasp the objective of the issue you've opened.

I've started contributing to this package very recently (last 2 weeks), and agree with you that many implementation details aren't ideal for people like us interested in the mathematical properties involving these geometrical concepts. My understanding is that the GeometryBasics.jl package has been initiated for visualization purposes in the Makie.jl ecosystem and then evolved after the fact to incorporate more concepts from other packages in JuliaGeometry and JuliaGeo. I wonder if foundational changes like the ones we are discussing here will be welcome. I am waiting for @SimonDanisch to review #101 before I continue with my work. If he feels that the changes in that PR are breaking and unwelcome, I will have to fork the project and work on my own. My research relies on a better approach to geometry than what this package is currently offering.

JeffreySarnoff commented 3 years ago

I just wanted to write it so my thoughts for a possible future direction would keep.