hexagon logo

How to calculate arc points with an angle, center point and radius

I am putting this here because others may use it.

How to find point x,y and i,j on an arc at specific angles

ASSIGN/V1=ARRAY("Center X","Center Y","Center Z")
ASSIGN/V2="Radius of Circle"
ASSIGN/V3="First Angle"
ASSIGN/V4="Second Angle"
ASSIGN/V5=3.141592654
ASSIGN/V6=ARRAY(FORMAT("%.8F",V1[1]+(V2*(COS(V3/(180/V5))))),FORMAT("%.8F",V1[2]+(V2*(SIN(V3/(180/V5))))),V1[3],FORMAT("%.8F",COS(V3/(180/V5))),FORMAT("%.8F",SIN(V3/(180/V5))),0)
ASSIGN/V7=ARRAY(FORMAT("%.8F",V1[1]+(V2*(COS(V4/(180/V5))))),FORMAT("%.8F",V1[2]+(V2*(SIN(V4/(180/V5))))),V1[3],FORMAT("%.8F",COS(V4/(180/V5))),FORMAT("%.8F",SIN(V4/(180/V5))),0)
  • I believe the letter F needs to be lowercase in the FORMAT statement
    FORMAT(“%.8f”,***********)
  • probably.
    It may have changed it after i copy/paste.
  • Another way to do it, with some assignments, when the circle isn't along Z axis.(In a first time, it works if the circle is aligned on origin : a line between origin and the center is perp to the circle - I will add some changes ASAP if the circle isn't aligned)

    If you begin by this thread on monday morning, please have one or two coffee(s) before continuing Slight smile !

    First, a little maths explaining the method using rotation matrices :


    The first matrix turns around Z, the second around Y1 and the third around X2. E represents the whole rotation.

    Then, some assignments :

    ASSIGN/V1=CIRC1.XYZ
    ASSIGN/V2=CIRC1.IJK
    ASSIGN/V3=CIRC1.R
    ASSIGN/R1=SQRT(DOT(CIRC1.XYZ,CIRC1.XYZ))
    ASSIGN/ALPHA=ATAN(CIRC1.J/CIRC1.I)
    ASSIGN/BETA=DEG2RAD(ANGLEBETWEEN(CIRC1.IJK,ALIGN1.ZAXIS))
    ASSIGN/GAMMA=0 (or DEG2RAD(C1.INPUT) if you want to enter a value)


    A first point at “0°” can be calculated using the matrix D (or E with GAMMA=0 !)

    ASSIGN/COOR_INIT_PT1=MPOINT(R1,V3,0)
    ASSIGN/M_RAW_1=MPOINT(COS(ALPHA)*COS(BETA),SIN(ALPHA)*COS(BETA),SIN(BETA))
    ASSIGN/M_RAW_2=MPOINT(-SIN(ALPHA)*COS(GAMMA)-COS(ALPHA)*SIN(BETA)*SIN(GAMMA), COS(ALPHA)*COS(GAMMA)-SIN(ALPHA)*SIN(BETA)*SIN(GAMMA),COS(BETA)*SIN(GAMMA))
    ASSIGN/M_RAW_3=MPOINT(-SIN(ALPHA)*SIN(GAMMA)-COS(ALPHA)*SIN(BETA)*COS(GAMMA), -COS(ALPHA)*SIN(GAMMA)-SIN(ALPHA)*SIN(BETA)*COS(GAMMA),COS(BETA)*COS(GAMMA))
    ASSIGN/COOR_PT1=MPOINT(DOT(COOR_INIT_PT1,M_RAW_1), DOT(COOR_INIT_PT1,M_RAW_2), DOT(COOR_INIT_PT1,M_RAW_3))


    The coordinates of a point with GAMMA=10° uses the same way, with :

    ASSIGN/GAMMA=DEG2RAD(10)
    ASSIGN/COOR_INIT_PT_10=MPOINT(R1,V3*COS(GAMMA),V3*SIN(GAMMA))


    For those calculations, I assume that the circle is not along (0,01) vector.
    I use the actual coordinates of the circle, I transpose them as if they were along X axis and I apply the matrix.
  • Jefman, are those formulas for rotating of the axes?

    It’s just past noon now (started today at 2:30 a.m.) and my head still isn’t clear enough to follow. Confused
  • Jefman, are those formulas for rotating of the axes?

    It’s just past noon now (started today at 2:30 a.m.) and my head still isn’t clear enough to follow. Confused


    Yes, i use rotation formulas to create the points.
    Ok, it's a strange way to do it !
    I assume that it's more simple to "move" a point from an init fictive position to a real one.
    I believe that it could be done with a double cross product, but I have to work around a little... Maybe on friday or next week-end if it's raining !
  • Matrix Rotation. Awesome.

    I was trying to figure how to relate the math expressions into code a while ago, and I had trouble.

    This is way cool.
  • Heh, that's kinda nifty.

    I'm totally saving this.