hexagon logo

Generic line from 2 generic points

Hi,
How would you construct a generic line from 2 generic points, correctly oriented ? (from point 1 to point 2)


I'm scanning an hexagonal part to find the closest point to its centre.

AFFECTER/V1=SCN2.HIT[1..SCN2.NUMHITS].XYZ*MPOINT(1,1,0)
AFFECTER/V2=MININDEX(SQRT(DOT(V1,V1)))
AFFECTER/V3=SCN2.HIT[V2].XYZ => generic point 2
AFFECTER/V4=SCN2.XYZ*MPOINT(0,0,1) => generic point 1 (center)
AFFECTER/VECT_1=UNIT(V3-V4) => I tried UNIT(V4-V3) but there is no incidence ???????​
  • You could try
    ASSIGN/VECT1=UNIT(MPOINT(SCN2.HIT[V2].X,SCN2.HIT[V2].Y,-SCN2.Z))
    (because vector from 1 to 2 is PT2-PT1. PT1.X=PT1.Y=0 ; PT2.Z=0)

    F1 =GENERIC/LINE,DEPENDENT,CARTESIAN,$
    NOM/XYZ,<0,0,PT1.Z>,$
    MEAS/XYZ,<0,0,PT1.Z>,$
    NOM/IJK,<VECT1.I,VECT1.J,VECT1.K>,$
    MEAS/IJK,<VECT1.I,VECT1.J,VECT1.K>
    LENGTH/10,10​
  • So it appears you have a measured scan.
    I'd align/origin to the center to the scan (presuming you have a means to consistently control rotation)
    construct a generic plane and construct intersect points between the scan and the plane, then again between the plane and the scan.
    construct a line between the two points.
    I have the same scenario, and i do this (well i actually just take 2-hit lines on each face, not a scan) 3x to determine my hexagon-shaped bore with a max inscribed diameter specification.
  • So it appears you have a measured scan.
    I'd align/origin to the center to the scan (presuming you have a means to consistently control rotation)
    construct a generic plane and construct intersect points between the scan and the plane, then again between the plane and the scan.
    construct a line between the two points.
    I have the same scenario, and i do this (well i actually just take 2-hit lines on each face, not a scan) 3x to determine my hexagon-shaped bore with a max inscribed diameter specification.


    You can't intersect directly a scan with a plane.
    You can create a curve from the scan, with a little tol (0.00001) to get the same number of points, and then intersect the curve with the plane.
    You can also search the two ponts on each side of the plane, and create a line between them (i think there's a code somewhere here, but I don't remember where...)
    Something like :
    ASSIGN/V1=MININDICES(ABS(DOT(SCN1.HIT[1..SCN1.NUMHITS].XYZ-PL1.XYZ,PL1.IJK)))
    ASSIGN/V2=UNIT(SCN1.HIT[V1[2]].XYZ-SCN1.HIT[V1[1]].XYZ)
    ASSIGN/V3=DOT(V2,PL1.IJK)
    ASSIGN/V4=SCN1.HIT[V1[1]].XYZ
    IF/V3<0
    ASSIGN/V4=SCN1.HIT[V1[2]].XYZ
    END IF/
    ASSIGN/V5=DOT(V4-PL1.XYZ,PL1.IJK)/V3
    ASSIGN/V6=V4+V5*V2
    F1 =GENERIC/POINT,DEPENDENT,CARTESIAN,$
    NOM/XYZ,<V6.X,V6.Y,V6.Z>,$
    MEAS/XYZ,<V6.X,V6.Y,V6.Z>,$
    NOM/IJK,<0,0,1>,$
    MEAS/IJK,<0,0,1>


    You can check that F1 is on the plane with ASSIGN/V7=DOT(F1.XYZ-PL1.XYZ,PL1.IJK) ; V7 should be =0 (I'm not at the cmm; it's late... maybe V4 depends on V3>0...)​
  • Hi,
    It worked Jef. I did several tests, it seems to work every single time.

    AFFECTER/V1=SCN1.HIT[1..SCN1.NUMHITS].XYZ*MPOINT(1,1,0)
    AFFECTER/V2=MININDEX(SQRT(DOT(V1,V1)))
    AFFECTER/V3=SCN1.HIT[V2].XYZ
    AFFECTER/V4=V3*MPOINT(0,0,1)
    AFFECTER/VECT1=UNIT(MPOINT(SCN1.HIT[V2].X,SCN1.HIT[V2].Y,-SCN1.Z))
    DROITE_7PANS=GÉNÉRIQUE/DROITE,DÉPENDANT,CARTÉSIEN,$
    VAL. NOM. /XYZ,<0,0,V3.Z>,$
    MESU/XYZ,<0,0,V3.Z>,$
    VAL. NOM. /IJK,<VECT1.I,VECT1.J,VECT1.K>,$
    MESU/IJK,<VECT1.I,VECT1.J,VECT1.K>,$
    DISTANCE/10,10
    A4 =ALIGNEMENT/DÉPART,RAPPEL:A1IGNEMENT EXTER,LISTE=OUI
    ALIGNEMENT/ROTATION,XPLUS,VERS,DROITE_7PANS,À PROPOS,ZPLUS
    ALIGNEMENT/FIN
    PLAN TRAVAIL/ZPLUS
    PLAN SÉCU/ZPLUS,50,ZPLUS,250,ON
    DÉPLACER/PLAN SÉCURITÉ


    FACE1_1 =ÉLÉM/CONTACT/POINT DE VECTEUR/PAR_DÉFAUT,CARTÉSIEN
    THÉO/<-7.3892,-9.7801,-33.3>,<-0.6802415,-0.7329881,0>
    RÉEL/<-8.1352,-10.594,-33.3057>,<-0.6802415,-0.7329881,0>
    CIBLE/<-7.3892,-9.7801,-33.3>,<-0.6802415,-0.732988,0>
    ALIGNEMENT=NON
    AFFICHER PARAMÈTRES ÉLÉMENTS=NON
    AFFICHER PARAMÈTRES CONTACTS=OUI
    DÉPLACEMENT D'ÉVITEMENT=NON,DISTANCE=10
    AFFICHER PALPAGES=NON



    The only issue is the following FACE1_1 element, I had set predefined theoritical values for X,Y,Z, but it keeps replacing its coordinates when I change the hexagonal part position.
    Any idea why ? ​


  • The only issue is the following FACE1_1 element, I had set predefined theoritical values for X,Y,Z, but it keeps replacing its coordinates when I change the hexagonal part position.
    Any idea why ? ​


    Maybe because the alignment changes.
    Assign theo values (as a mpoint for example), the use Vxx.X,Vx.Y and Vxx.Z as theo and target values. (also for IJK !)
  • It's funny because I've never seen this before. The alignment was randomly misoriented according to X+ or X-, but it had never reset coordinates.
    And now that the alignment is correct, it now randomly reset coordinates Smiley

    I will use variable, thanks Jef