hexagon logo

Does anyone know an easy way to project all the points in a group to a plane?

I have a group of points (a plane for example) and I want to project them all to a plane (simplest case == WORKPLANE). Is there some smart way to do it all at once (a.k.a. "the JEFMAN way") or is it only possible with a loop? I haven't found anything yet...

The object of this is to create a secondary tangent plane perpendicular to the primary by the following method:

- measure the secondary plane
- project all points up/down to the primary (WORKPLANE)
- construct a tangent plane from the original plane points + the projected points (guaranteed to be perpendicular to the primary as that is our projection direction)

As a follow-up question: How can I use an ARRAY variable in the same way as .HIT[...] in the construction of a tangent plane?
  • I'm beginning to suspect one actually has to do all the steps the Help describes for Tangent Plane - we have been ignoring Void filtering (Convex Hull) so far, maybe that's why results sometimes get strange. I've written a simple Convex Hull calculation (in plain PC-DMIS code, thus slow) to reduce the number of points of interest. Will test the combination when time permits (probably Friday afternoon).


    I played a little with your code, I just add a loop at the start (*100) and look when there's a value of Y <0.
    I saw that there was more than 25% of errors !!!!
    In the loop, I also add a file/write in an if statement (when there's a value <0) where I write the number of the loop, the y value and both points with the min value. It was always points 1 and 2 ! ???
    I change the minimax to L2 constraint, and get less errors.
    I add a report comment after each random, and get once zero error, and once 1%.

    It's one of the pc-dmis problems, sometimes, the prog works too fast, and the values are not updated as they should...

    I will continue ASAP Wink
  • Could be the synthetic testdata: Points 1 and 2 are on the same X, different Z, only Y has random - when you generate the V7 point they will all be on a straight line above each other, no good plane. Found this when I ran with random turned off. But off course, this can also happen with real hits, although not very probable. But the plane may be very sensitive to variations if the points are close.
  • OK, I've officially given up on this method. Even if I can get something to always calculate the 'right thing' (I doubt it), it will be too cumbersome to add it to a part program that would benefit from it. My new approach to finding a tangent secondary plane, perpendicular to the primary, is using alignments to do the work instead.

    The idea is as follows - prerequisites: a coarse alignment (6DOF) done, a fine primary (ZPLUS) alignment done, a plane measured on the secondary (in my test case PNT2-PNT7) for the YMINUS direction.
    1. Create a Tangent plane of the points
    2. Align (Rotate) to that
    3. Find the hit of the tangent plane that is furthest away in YMINUS
    4. Move the origin in Y to that hit
    5. Find the hit that is next to furthest away
    6. Calculate a rotation delta that would make the X-axis pass through both these points
    7. Move the origin i X to the first hit (3 above)
    8. Rotate the alignment around Z (amount from calculation (6))
    9. Move the alignment back to it's original X position
    10. (Optional) Verify that at least two of the points of the plane touches

    PLN4 =FEAT/PLANE,CARTESIAN,OUTLINE,NO
    THEO/<101.833,0,-17.333>,<0,-1,0>
    ACTL/<101.85,-2.622,-17.313>,<0.0175987,-0.999609,0.0217306>
    CONSTR/PLANE,TANGENT,PNT2,PNT3,PNT4,PNT5,PNT6,PNT7,,
    MATH_TYPE/CONSTRAINED_MINMAX,BF
    
    A2 =ALIGNMENT/START,RECALL:A1,LIST=YES
    ALIGNMENT/ROTATE,YMINUS,TO,PLN4,ABOUT,ZPLUS
    ALIGNMENT/END
    
    ASSIGN/VI1=MININDEX(PLN4.HIT[1..PLN4.NUMHITS].Y)
    
    A3 =ALIGNMENT/START,RECALL:A2,LIST=YES
    ALIGNMENT/TRANS_OFFSET,YAXIS,PLN4.HIT[VI1].Y
    ALIGNMENT/END
    
    ASSIGN/VI2=MININDICES(PLN4.HIT[1..PLN4.NUMHITS].Y)
    
    ASSIGN/ANG=ATAN(PLN4.HIT[VI2[2]].Y/(PLN4.HIT[VI2[2]].X - PLN4.HIT[VI1].X))/3.1415927*180
    
    A4 =ALIGNMENT/START,RECALL:A3,LIST=YES
    ALIGNMENT/TRANS_OFFSET,XAXIS,PLN4.HIT[VI1].X
    ALIGNMENT/END
    
    A5 =ALIGNMENT/START,RECALL:A4,LIST=YES
    ALIGNMENT/ROTATE_OFFSET,ANG,ABOUT,ZPLUS
    ALIGNMENT/END
    
    A6 =ALIGNMENT/START,RECALL:A5,LIST=YES
    ALIGNMENT/TRANS,XAXIS,PNT1
    ALIGNMENT/END
    
    ASSIGN/V6=PLN4.HIT[1..PLN4.NUMHITS].Y
    COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    V6
    


    Note: This will not give a 'balanced' tangent plane (CONSTRAINED_MINMAX), but one that tries to touch at least two points of the plane, and will fail miserably if the two high points have the same X value...

    Please find all errors and loopholes!
  • Nice code, !
    I think you could :
    ASSIGN/VI=MININDICES(PLN4.HIT[1..PLN4.NUMHITS].Y
    ASSIGN/VI1=VI[1]
    ASSIGN/VI2=VI[2]
    then origin on PLN4.HIT[VI1] (so using XYZ) and rotate from PLN4.HIT[VI1] to PLN4.HIT[VI2] in A3.

    Just a thought : in ANG, why don't you use RAD2DEG, instead of 3.1415927/180 ?
    And why don't you use ACOS(-1) for Pi ? Slight smile
  • Just a thought : in ANG, why don't you use RAD2DEG, instead of 3.1415927/180 ?
    And why don't you use ACOS(-1) for Pi ? Slight smile


    Because I want to show off my knowledge of the Pi decimals, of course! Or maybe because I work in many different programming languages/environments and neither RAD2DEG nor ACOS exist in all of them (at least not under the same names), so I take the easy way out...

    Will ponder your other suggestion when time permits...
  • Update:

    I've revised the method a bit further, as the previous one was of course not completely correct, and could still generate alignments where some point(s) of the plane ended up on the wrong side.

    This one has so far always generated an alignment which (a) touches at least one of the original hits, (b) leaves all the hits on, or on the same side of, the coordinate plane. Of course, that's no guarantee that it will always do that, but I haven't manage to provoke an error yet...

    Note that the final alignment plane is neither exactly L1, L2 or MINMAX, but just "a plane that satisfies the conditions: tangent plane, perpendicular to the primary".

    Also note that the code as written expects ZPLUS to be primary, and will align YMINUS to the secondary plane.

    I would be happy for any verifications/refutations you can provide!


    The current steps are:
    1. Create a Tangent plane of the points
    2. Align (Rotate) to that
    3. Find the hit of the tangent plane that is furthest away in YMINUS
    4. Move the origin in Y to that hit
    5. Find the hit with the smallest polar angle in this coordinate system, remember the angle
    6. Move the origin in X to the first hit (3 above)
    7. Rotate the alignment around Z (amount from (5))
    8. Move the alignment back to it's original X position
    9. (Optional) Verify that at least one of the points of the plane touches, and all the others are on the same side

    $$ NO,
                (1)
                .
    PL1        =FEAT/PLANE,CARTESIAN,TRIANGLE,NO
                THEO/<108.5,0,-14.8333>,<0,-1,0>
                ACTL/<108.8336,-0.5148,-14.835>,<0.0011097,-0.9999797,-0.006276>
                CONSTR/PLANE,TANGENT,F1,F2,F3,F4,F5,F51,,
                MATH_TYPE/CONSTRAINED_MINMAX,BFRE
    $$ NO,
                (2)
                .
    A2         =ALIGNMENT/START,RECALL:A1,LIST=YES
                  ALIGNMENT/ROTATE,YMINUS,TO,PL1,ABOUT,ZPLUS
                ALIGNMENT/END
    $$ NO,
                (3)
                .
                ASSIGN/VI2=MININDICES(PL1.HIT[1..PL1.NUMHITS].Y)
                ASSIGN/VI1=VI2[1]
                ASSIGN/Y1=PL1.HIT[VI1].Y
    $$ NO,
                (4)
                .
    A3         =ALIGNMENT/START,RECALL:A2,LIST=YES
                  ALIGNMENT/TRANS_OFFSET,YAXIS,Y1
                ALIGNMENT/END
    $$ NO,
                (5)
                .
                ASSIGN/ANG=RAD2DEG(ATAN(PL1.HIT[1..PL1.NUMHITS].Y/(PL1.HIT[1..PL1.NUMHITS].X - PL1.HIT[VI1].X)))
                ASSIGN/AANG=ABS(ANG)
                ASSIGN/IANG=MININDEX(AANG)
                ASSIGN/ANGT=ANG[IANG]
    $$ NO,
                (6), (7), (8)
                .
    A4         =ALIGNMENT/START,RECALL:A3,LIST=YES
                  ALIGNMENT/TRANS_OFFSET,XAXIS,PL1.HIT[VI1].X
                  ALIGNMENT/ROTATE_OFFSET,ANGT,ABOUT,ZPLUS
                  ALIGNMENT/TRANS,XAXIS,PNT_C
                ALIGNMENT/END
    $$ NO,
                (9)
                .
    DIM LOC1= LOCATION OF POINT F1  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX    NOMINAL       MEAS       +TOL       -TOL        DEV
    Y       0.0000     0.2217     0.0500    -0.0500     0.2217 -------->
    END OF DIMENSION LOC1
    DIM LOC2= LOCATION OF POINT F2  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX    NOMINAL       MEAS       +TOL       -TOL        DEV
    Y       0.0000     0.0000     0.0500    -0.0500     0.0000 ----#----
    END OF DIMENSION LOC2
    DIM LOC3= LOCATION OF POINT F3  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX    NOMINAL       MEAS       +TOL       -TOL        DEV
    Y       0.0000     0.4962     0.0500    -0.0500     0.4962 -------->
    END OF DIMENSION LOC3
    DIM LOC4= LOCATION OF POINT F4  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX    NOMINAL       MEAS       +TOL       -TOL        DEV
    Y       0.0000     0.6424     0.0500    -0.0500     0.6424 -------->
    END OF DIMENSION LOC4
    DIM LOC5= LOCATION OF POINT F5  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX    NOMINAL       MEAS       +TOL       -TOL        DEV
    Y       0.0000     0.0000     0.0500    -0.0500     0.0000 ----#----
    END OF DIMENSION LOC5
    DIM LOC6= LOCATION OF POINT F51  UNITS=MM ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH  HALF ANGLE=NO
    AX    NOMINAL       MEAS       +TOL       -TOL        DEV
    Y       0.0000     0.0988     0.0500    -0.0500     0.0988 -------->
    END OF DIMENSION LOC6
    
  • Now... include that code into PC-DMIS so the only thing we math illiterates will need to do is measure a plane and click a button.

    Thanks in advance!

    Sunglasses
  • Coming in 2019 R1...... Constructed Secondary Datum Line and Constructed Tertiary Datum Point (we also renamed Tangent plane to: Primary Datum Plane). The primary, secondary and tertiary constructed datum features represent a datum reference frame of 3 planes external to material and nominally constrained in orientation (tertiary datum can be at basic angle other than 90 from secondary).
  • Coming in 2019 R1...... Constructed Secondary Datum Line and Constructed Tertiary Datum Point (we also renamed Tangent plane to: Primary Datum Plane). The primary, secondary and tertiary constructed datum features represent a datum reference frame of 3 planes external to material and nominally constrained in orientation (tertiary datum can be at basic angle other than 90 from secondary).


    Thanks, Rob !
    Good news !
    Maybe a "back enhancement" to previous versions should be also a good point...