bugpyFormex - Bugs: bug #41564, geomtools.distance of points from...


bug #41564: geomtools.distance of points from planes

Submitter:  gianluca de santis <gianlucadesi>
Submitted:  Wed 12 Feb 2014 10:33:22 AM UTC
Category:  Core Severity:  1 - Wish
Item Group:  Feature request Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup

Thu 13 Feb 2014 07:29:25 PM UTC, comment #4: 

I attached a file with proposed name changes. Some cases are not decided yet. Comments welcome.

We should also add the mode = 'all'/'pair' to (almost) all two-object operations (intersect,project,distance).

(file #30540)

Benedict Verhegghe <bverheg>
Group administrator
Wed 12 Feb 2014 04:56:06 PM UTC, comment #3: 

I do not like these shortened names POP, LWP, etc, which give no clue as to what they do. I propose to use full names that clearly specify the purpose. If the user looks in the index under intersection, and sees a function intersectionLineWithPlane, he can get an idea what it does and whether it is interesting to explore that function. But if you see a lot of intersectionXYZ, you probably do not even bother to start reading.

Also, the functions can all be named after single case operation, even if they work on multiple objects as well.

Next, there should not be any hidden geometry in the naming. E.g., intersectionPointsPOP (intersection points of perpendiculars through points on planes).

Then, the result of the operation should not be mentioned, if the result is unique. The educated user knows what the intersection is of the geometrical entities involved.

In cases where two functions do the same, but one returns the resulting geometry, the other the parametric values, the first one should not mention the return type, while the latter gets the addition ...Times.
Or we could add an option to the above function to return the parametric values instead. Please give preference, if any.

Finally, we can shorten the names by not using the noun but the verb form of the operation.

Thus e.g. some name changes could be:

intersectionPointsPOP -> projectPointOnPlane

intersectionPointsLWP -> intersectLineWithPlane

intersectionTimesLWP -> intersectLineWithPlaneTimes or intersectLineWithPLane(times=True) ?

Any comments? Any additional rules?
If ok, we can make a renaming table to see if we can cover everything.

Another possible track would be to create Line, Plane, Segment, Vector, ... classes, that could be used to check/reshape the input arrays, and then have simple project/intersect methods.
This could also be done as a second step after the renaming of geomtools methods. The Coords(X).project(Y) would call geomtools.projectPointOnPlane if Y is a Plane object, and geomtools.projectPointOnLine if Y is a Line object.

Benedict Verhegghe <bverheg>
Group administrator
Wed 12 Feb 2014 03:46:54 PM UTC, comment #2: 

Sorry, this is indeed what happened: I looked into geomtools.py (where similar functions are located) but not in coords.py!
I agree to add the full functionality in geomtools and then call it by a corresponding Coords method. I think that geomtools is already nicely structured, apart from the fact that P can mean either point or plane, and this can be confusing such as:

intersectionTimesPOP = points on planes
intersectionTimesPOL = points on lines
intersectionTimesSWP = segments with planes

Should a point be represented by a X instead?
We could then add a commented list to explain:

X point
P plane
V vector
L line
S segment
T triangle

gianluca de santis <gianlucadesi>
Group Member
Wed 12 Feb 2014 02:04:54 PM UTC, comment #1: 

There is already Coords.distanceFromPlane. I am not sure if it supports multiple planes (distanceFromLines does). So I would not like to add more confusion on what to use when: Coords.distanceFromPlane or geomtools.distancesPFP.
The same holds for Coords.projectOnPlane, which is the same as geomtools.intersectionPointsPOP.

I think we need to clean this up by

- renaming the functions/methods appropriately,
- checking which implementation is the best,
- adding the full functionality in one place: this can either be  a Coords method, or a function in geomtools which is then called by the Coords method.

This may be a good occasion to start doing so.

Benedict Verhegghe <bverheg>
Group administrator
Wed 12 Feb 2014 10:33:22 AM UTC, original submission:  

I think that this function is missing in geomtools. Could you please check if it fits there?

def distancesPFP(X,p,n,mode='all'):
    """Return the distances of points X from planes (p,n).

    - `X`: a (nX,3) shaped array of points (`mode=all`)
      or broadcast compatible array (`mode=pair`).
    - `p`,`n`: (np,3) shaped arrays of points and normals, defining a single
      plane or a set of planes.
    - `mode`: `all` to calculate the distance of each point X from
      all planes (p,n) or `pair` for pairwise distances.
    Returns a (nX,np) shaped (`mode=all`) array of distances.
    Y = intersectionPointsPOP(X, p, n, mode)
    if mode == 'all':
        X = asarray(X).reshape(-1, 1, 3)
    return length(Y-X)

gianluca de santis <gianlucadesi>
Group Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #30540:  geomtools.txt added by bverheg (2KiB - text/plain)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by bverheg (Posted a comment)
  • -email is unavailable- added by gianlucadesi (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-02-13 bverheg Attached File- Added geomtools.txt, #30540
    2014-02-12 bverheg CategoryNone Core
        Severity3 - Normal 1 - Wish

    Back to the top

    Powered by Savane 3.13-04b1.
    Corresponding source code