octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: plotted circle is regular decagon on opengl graphics


From: Daniel J Sebald
Subject: Re: plotted circle is regular decagon on opengl graphics
Date: Fri, 12 Aug 2016 13:33:23 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2

On 08/12/2016 12:13 AM, Daniel J Sebald wrote:
On 08/11/2016 03:28 PM, Robert Funnell wrote:
On Thu, 11 Aug 2016, Rik wrote:

The performance cost is the cos/sin computations, not the underlying
driver.  The driver essentially sweeps out the same arc no matter how
fine the angular resolution is (i.e., it may draw more polygon lines,
but
the individual polygon lines are shorter so don't need as many
computations to complete).

I'm happy to have something different in place.  The procedure here
(http://slabode.exofire.net/circle_draw.shtml) uses only multiplications
and additions and is possibly faster than either the trig approach or
the
sqrt approach.  Probably easy to benchmark all three options since the
only
thing that needs testing is the creation of the vertex points, not the
actual calls to OpenGL.

These are nice Rik.  It's sort of a differential approach.  I actually
like the vector rotation at first blush, and since you already have the
increment-angle calculation code you'd just need to compute the angular
rotation matrix at the start.  The tangent-subtraction algorithm
probably works fine with floating point precision, the risk being that
any inaccuracy of the computation could accumulate and the start and end
points don't quite meet up correctly.

Here's a patch that uses rotation matrix

[xnew]   [m11  m12] [x]
|    | = |        | | |
[ynew]   [m21  m22] [y]

Here's my very rough estimate for drawing three million circles:

graphics_toolkit ('qt');
plot(rand(3000000,1), rand(3000000,1), 'or');
set(get(gca,'children'),'MarkerSize',10); ## Start counting until figure refresh set(get(gca,'children'),'MarkerSize',100); ## Start counting until figure refresh

                  3M size 10   3M size 100
                  ----------   -----------
rotation matrix:     15 s          24 s
  trigonometric:     15 s          27 s
           sqrt:     18 s          25 s

OpenGL must store the polygon vertices for redraw because this consumes a lot of memory. By my guess, the sqrt method uses about 40% more memory, so it is probably more granulation than necessary.

One could play games of trying to minimize the number of vertices, but I don't think it is too critical as it seems to me the underlying OpenGL routines are what's consuming the most CPU time. All of the above routines seem adequately efficient.

Dan

Attachment: octave-nontrig_circle_symbol-djs2016aug12.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]