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 can't find a good solution without looping Disappointed !
    PL1 and PL2 are tangent planes using Minimax option.

    AFFECTER/V2=PL1.XYZ-CROSS(CROSS(PL2.HIT[1..PL2.NUMHITS].XYZ-PL1.XYZ,PL1.IJK),PL1.IJK)*SQRT(DOT(PL2.HIT[1..PL2.NUMHITS].XYZ-PL1.XYZ,PL2.HIT[1..PL2.NUMHITS].XYZ-PL1.XYZ))*SIN(DEG2RAD(ANGLEBETWEEN(PL2.HIT[1..PL2.NUMHITS].XYZ-PL1.XYZ,PL1.IJK)))
    V3         =BOUCLE/DÉPART,ID=OUI,NOMBRE=PL2.NUMHITS,DÉPART=1,IGNORER=,
                  DÉCALAGE:AXEX=0,AXEY=0,AXEZ=0,ANGLE=0
                  AFFECTER/V4=V2[V3]
    F3           =GÉNÉRIQUE/POINT,DÉPENDANT,CARTÉSIEN,$
    VAL. NOM.     /XYZ,<V4.X,V4.Y,V4.Z>,$
                  MESU/XYZ,<V4.X,V4.Y,V4.Z>,$
    VAL. NOM.     /IJK,<0,1,0>,$
                  MESU/IJK,<0,1,0>
                BOUCLE/FIN
    SCN6       =ÉLÉM/SÉRIE,CARTÉSIEN
                THÉO/<24.9837,-0.0255,0>,<0,0,1>
                RÉEL/<24.9837,-0.0255,0>,<0,0,1>
                CONSTR/SÉRIE,BASE,F3[1..PL2.NUMHITS],,
    SCN8       =ÉLÉM/SÉRIE,CARTÉSIEN
                THÉO/<24.9837,-0.0255,14.9765>,<0,0,1>
                RÉEL/<24.9837,-0.0255,14.9765>,<0,0,1>
                CONSTR/SÉRIE,BASE,PL2.HIT[1..PL2.NUMHITS],SCN6.HIT[1..PL2.NUMHITS],,
    PL3        =ÉLÉM/PLAN,CARTÉSIEN,TRIANGLE,NON
                THÉO/<24.9837,0.0074,14.9765>,<0.0004654,0.9999999,0>
                RÉEL/<24.9837,0.0074,14.9765>,<0.0004654,0.9999999,0>
                CONSTR/PLAN,TANGENTE,SCN8,,
                TYPE_MATH/CONTRAINT_MINMAX,BFRE



    I'd look at another solution using the intersection between both tangent planes, the max distance between hits and line perp to the line, then create a generic plane :


    LN1        =ÉLÉM/LIGNE,CARTÉSIEN,ILLIMITÉ,NON
                THÉO/<24.9927,0.0062,0>,<1,0.0000829,0>
                RÉEL/<24.9927,0.0062,0>,<1,0.0000829,0>
                CONSTR/DROITE,INTER DE,PL2,PL1
                AFFECTER/V5=CROSS(PL1.IJK,LN1.IJK)
                AFFECTER/V6=MAXINDEX(DOT(PL2.HIT[1..PL2.NUMHITS].XYZ-LN1.XYZ,V5))
                AFFECTER/V8=MAXINDICES(DOT(PL2.HIT[1..PL2.NUMHITS].XYZ-LN1.XYZ,V5))
                AFFECTER/V7=PL2.HIT[V6].XYZ
    F4         =GÉNÉRIQUE/PLAN,DÉPENDANT,CARTÉSIEN,$
    VAL. NOM.   /XYZ,<V7.X,V7.Y,V7.Z>,$
                MESU/XYZ,<V7.X,V7.Y,V7.Z>,$
    VAL. NOM.   /IJK,<V5.I,V5.J,V5.K>,$
                MESU/IJK,<V5.I,V5.J,V5.K>


    It gives a plane F4 perp to PL1, but with a tangent in a lonely point, instead of 2.

    I'm wondering if the construction of a line through the first and the second values of V8 could give a better result which work whatever those values (if those values show hits which are aligned along PL1 vector, it can't work...)


  • Even 'rubbish' can give ideas! The tangent plane construction gives a plane where all hits are on one side of the plane. It works perfectly for a primary datum, but is not enough for a secondary, as this should be constructed with the additional constraint of being perpendicular to the primary.

    I *think* my method will work (with some modifications, I *do* know of one loophole...), but I want to get rid of the separate projection of every hit.
  • That's quite an assignment expression!!!!!
  • Just a word of warning if you start experimenting with this: The method, as I have described it, will not work on all configurations of hits and deviations. I think I have the solution for that, but more verification is needed, and I really want to solve the projection part first, as all this will be impractical unless that can be accomplished in a few lines (without loops, as that would be much too slow).
  • What do you mean you don't have the direction yet? Presumably you have at least performed a manual alignment, if not a proper DCC alignment as well. And the points are all (0,-1,0). If they weren't, you would just use the T value (or always just use the T value regardless.)

    In either case, with PC-DMIS, you would almost always be required to have a rough alignment first (PC-DMIS just doesn't have the tools yet, like PolyWorks does). So, this would be (at the earliest) your 3rd alignment, or if you are using Xact, this would be the feature that you end up using as your Defined Datum. You could even do "iterations" of the *Find Max, create generic on Max point at defined IJK* process until you were happy with it.

    I get what you're asking for, but I think PC-DMIS just isn't well equipped to do so.
  • I also tried :
    ASSIGN/V1=MPOINT(1,1,0)
    then create a feature set with SCN1.HIT[1..SCN1.NUMHITS]*V1, which is exactly the projection on Z plane, but it doesn't work Disappointed.
    I also tried using a COP, no more effect.

    I believe that the solution is in a script...
    But I'm waiting solution like a child about Santa Klaus !!!!!
  • I can't find a good solution without looping Disappointed !


    Neither can I. It's easy to get an array of the points, and to project them.

    I think two sets of projections are needed, so we can calculate a tangent plane without any interference from the original hits. At least that's the only way that seems to give consistent results irrespective of the pattern of hits (and deviations).

    V1 contains all hits projected to the workplane, in V2 are the same hits but 10 mm higher in Z):

                ASSIGN/V1=PLN4.HIT[1..PLN4.NUMHITS].XYZ*MPOINT(1, 1, 0)
                ASSIGN/V2=V1+MPOINT(0, 0, 10)
    


    but I can not find a way to use V1 and V2 in feature (or set) construction, even though the Help actually mentions something that sounds like it:


    For Best Fit (BF) or Best Fit Recompensate (BFRE) constructions, while you can use any feature type for your input features, BF and BFRE fit types are typically used with point features or point sets (a scan of points, a feature set with points, or an expression that resolves to an array of points).


    I'd like to write something like:

    PLN3       =FEAT/PLANE,CARTESIAN,OUTLINE,NO
                THEO/<-109,0,5>,<0,1,0>
                ACTL/<-109,1,5>,<0,1,0>
                CONSTR/PLANE,TANGENT[COLOR=#0000FF], [/COLOR][COLOR=#FF0000]V1, V2,,[/COLOR]
                MATH_TYPE/CONSTRAINED_MINMAX,BF
    


    but it either gets red, gives no result, or crashes PC-DMIS...

    Leaving me with a loop and generic array, just like you, and this is much too slow if I try it on a scanned plane.

    Edit: It's probably better if all vote for https://hexagonmi.userecho.com/communities/1/topics/23-drf-feature-construction-options-relative-to-other-featuresdatums so we get things like this for real...


  • You are right, I was thinking of a plane with no more that 20 points.
  • I tested this code offline, with 2 scans of 1000 hits, created under excel with a random.
    I checked the values with excel (minimax algo with the solver), it gives the same results.
    Maybe I've got it ?
    Some checks with real values would be welcome...

    PL1        =FEAT/PLANE,CARTESIAN,TRIANGLE,NO
                THEO/<0.0005,0,0.02>,<-0.0002001,0.0000008,1>
                ACTL/<0.0005,0,0.02>,<-0.0002001,0.0000008,1>
                CONSTR/PLANE,TANGENT,SCN1,,
                MATH_TYPE/CONSTRAINED_MINMAX,BFRE
    PL2        =FEAT/PLANE,CARTESIAN,TRIANGLE,NO
                THEO/<0,60.02,0.0005>,<0,1,-0.0002004>
                ACTL/<0,60.02,0.0005>,<0,1,-0.0002004>
                CONSTR/PLANE,TANGENT,SCN2,,
                MATH_TYPE/CONSTRAINED_MINMAX,BFRE
    DIM ANGL1= 3D ANGLE FROM PLANE PL1 TO PLANE PL2 ,$
    GRAPH=OFF  TEXT=OFF  MULT=10.00  OUTPUT=BOTH
    AX    NOMINAL       +TOL       -TOL       MEAS        DEV     OUTTOL
    A     269.9886     0.0100     0.0100   269.9886     0.0000     0.0000 ----#----
    LN1        =FEAT/LINE,CARTESIAN,UNBOUNDED,NO
                THEO/<0.0002,60.02,0.0199>,<-1,-0.0000001,-0.0002001>
                ACTL/<0.0002,60.02,0.0199>,<-1,-0.0000001,-0.0002001>
                CONSTR/LINE,INTOF,PL1,PL2
    REF1       =ALIGNMENT/START,RECALL[emoticon:6D505171FAA4497C85C5CA27290C555D]ÉMARRAGE,LIST=YES
                  ALIGNMENT/LEVEL,ZPLUS,PL1
                  ALIGNMENT/ROTATE,XPLUS,TO,LN1,ABOUT,ZPLUS
                ALIGNMENT/END
                ASSIGN/V1=SCN2.HIT[1..SCN2.NUMHITS].XYZ*MPOINT(1,1,0)
                ASSIGN/V2=CROSS(PL1.IJK,LN1.IJK)
                ASSIGN/V3=MAXINDICES(DOT(V1,V2))
                ASSIGN/V4=V3[1]
                ASSIGN/V5=V3[2]
                ASSIGN/V6=SCN2.HIT[V4].XYZ*MPOINT(1,1,0)
                ASSIGN/V7=SCN2.HIT[V5].XYZ*MPOINT(1,1,0)
                ASSIGN/V8=SCN2.HIT[V4].XYZ
    F1         =GENERIC/POINT,DEPENDENT,CARTESIAN,$
                NOM/XYZ,<V6.X,V6.Y,V6.Z>,$
                MEAS/XYZ,<V6.X,V6.Y,V6.Z>,$
                NOM/IJK,<0,1,0>,$
                MEAS/IJK,<0,1,0>
    F2         =GENERIC/POINT,DEPENDENT,CARTESIAN,$
                NOM/XYZ,<V7.X,V7.Y,V7.Z>,$
                MEAS/XYZ,<V7.X,V7.Y,V7.Z>,$
                NOM/IJK,<0,1,0>,$
                MEAS/IJK,<0,1,0>
    F3         =GENERIC/POINT,DEPENDENT,CARTESIAN,$
                NOM/XYZ,<V8.X,V8.Y,V8.Z>,$
                MEAS/XYZ,<V8.X,V8.Y,V8.Z>,$
                NOM/IJK,<0,1,0>,$
                MEAS/IJK,<0,1,0>
    PL3        =FEAT/PLANE,CARTESIAN,TRIANGLE,NO
                THEO/<1.5677,-59.9903,-16.6549>,<0.0000061,1,0>
                ACTL/<1.5677,-59.9903,-16.6549>,<0.0000061,1,0>
                CONSTR/PLANE,BF,F1,F2,F3,,
                OUTLIER_REMOVAL/OFF,3
                FILTER/OFF,WAVELENGTH=0
                ASSIGN/V9=MAX(DOT(SCN2.HIT[1..SCN2.NUMHITS].XYZ-PL3.XYZ,PL3.IJK))
                ASSIGN/V10=MIN(DOT(SCN2.HIT[1..SCN2.NUMHITS].XYZ-PL3.XYZ,PL3.IJK))


    The plane PL3 is constructed fom the min distance between SCN2.hits and the intersection line (I used MAXINDICES because the cross product V2 is along Y minus ; here there's an enhancement to provide !).
    I construct a generic point with this hit and with its projection on the plane + the second hit the closer of the line.
    V9 is 0, V10 is negative, so the plane is tangent, and PL3.K is 0, so the plane is perp to PL1.
    Excel gives the min distance = V10.

    No loop here Wink

    , even if it's not THE solution, I hope it's close to it...
  • Thanks for all your hard work JEFMAN, your examples have helped many of us here on the forum.

    Keep up the good work.