def render_arrow()

in fairmotion/viz/gl_render.py [0:0]


def render_arrow(p1, p2, D=0.1, color=[1.0, 0.5, 0.0], closed=False):
    quadric = gluNewQuadric()
    gluQuadricDrawStyle(quadric, GLU_FILL)
    gluQuadricNormals(quadric, GLU_SMOOTH)

    glColor(color)
    RADPERDEG = 0.0174533
    d = p2 - p1
    x = d[0]
    y = d[1]
    z = d[2]
    L = np.linalg.norm(d)

    glPushMatrix()

    glTranslated(p1[0], p1[1], p1[2])

    if x != 0.0 or y != 0.0:
        glRotated(math.atan2(y, x) / RADPERDEG, 0.0, 0.0, 1.0)
        glRotated(
            math.atan2(math.sqrt(x * x + y * y), z) / RADPERDEG, 0.0, 1.0, 0.0
        )
    elif z < 0:
        glRotated(180, 1.0, 0.0, 0.0)

    glTranslatef(0, 0, L - 4 * D)

    gluCylinder(quadric, 2 * D, 0.0, 4 * D, 32, 1)
    if closed:
        gluDisk(quadric, 0.0, 2 * D, 32, 1)

    glTranslatef(0, 0, -L + 4 * D)

    gluCylinder(quadric, D, D, L - 4 * D, 32, 1)
    if closed:
        gluDisk(quadric, 0.0, D, 32, 1)

    glPopMatrix()