exporting patch: # HG changeset patch # User Daniel J Sebald # Date 1470990389 18000 # Fri Aug 12 03:26:29 2016 -0500 # Node ID e6b3a5fcd3ee4c71e4e42da15f33a0858dce72f7 # Parent 16efd0403698c1736db5aeeeadf08738cfece1a8 Use rotation matrix multiplication for rendering a circle * gl-render.cc (make_marker_list): Rotate a vector starting at (sz/2,0) incrementally rather than use trig functions. diff --git a/libinterp/corefcn/gl-render.cc b/libinterp/corefcn/gl-render.cc --- a/libinterp/corefcn/gl-render.cc +++ b/libinterp/corefcn/gl-render.cc @@ -3845,11 +3845,21 @@ opengl_renderer::make_marker_list (const if (! (div % 2)) div += 1; // ensure odd number for left/right symmetry div = std::max (div, 5); // ensure at least a few vertices are drawn - double ang_step = M_PI / div; + float m11 = cos (M_PI/div); + float m21 = sin (M_PI/div); + float m12 = -m21; + float m22 = m11; + float x = sz/2; + float y = 0; + div *= 2; glBegin (filled ? GL_POLYGON : GL_LINE_LOOP); - for (double ang = 0; ang < 2*M_PI; ang += ang_step) - glVertex2d (sz/2*cos (ang), sz/2*sin (ang)); + for (int i = 0; i < div; i++) { + glVertex2d (x, y); + float xx = x; + x = m11*xx + m12*y; + y = m21*xx + m22*y; + } glEnd (); } break;