calculate displacements along axes
float dx = ( float ) ( ( l / Math . sqrt ( 1 + ( m * m ) ) ) * 0.5 ) ; float dy = m * dx ; a . x = p . x - dx ; a . y = p . y - dy ; d . x = p . x + dx ; d . y = p . y + dy ; b . x = q . x - dx ; b . y = q . y - dy ; c . x = q . x + dx ; c . y = q . y + dy ; } System . out . print ( ( int ) a . x + " , ▁ " + ( int ) a . y + " NEW_LINE" + ( int ) b . x + " , ▁ " + ( int ) b . y + "NEW_LINE" + ( int ) c . x + " , ▁ " + ( int ) c . y + " NEW_LINE" + ( int ) d . x + " , ▁ " + ( int ) d . y + "NEW_LINE"); }