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: Robert Funnell
Subject: Re: plotted circle is regular decagon on opengl graphics
Date: Thu, 11 Aug 2016 16:28:02 -0400
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

On Thu, 11 Aug 2016, Rik wrote:

On 08/11/2016 12:25 PM, address@hidden wrote:
Subject:
Re: plotted circle is regular decagon on opengl graphics
From:
Daniel J Sebald <address@hidden>
Date:
08/11/2016 12:25 PM

To:
Andreas Weber <address@hidden>, Tatsuro MATSUOKA
<address@hidden>, "address@hidden"
<address@hidden>

List-Post:
<mailto:address@hidden>
Precedence:
list
MIME-Version:
1.0
References:
<address@hidden>
<address@hidden>
In-Reply-To:
<address@hidden>
Message-ID:
<address@hidden>
Content-Type:
multipart/mixed; boundary="------------020400010901030207090104"
Message:
6


On 08/11/2016 03:12 AM, Andreas Weber wrote:
Hi Tatsuro,

Am 11.08.2016 um 08:17 schrieb Tatsuro MATSUOKA:
Graphics tool kit: qt and fltk
plot (1:1, 'o', 'markersize', 24)
print -depsc circle.eps
plotted circle is regular decagon (ugly).

The code to draw the markers with OpenGL is in gl-render.cc
opengl_renderer::make_marker_list

     case 'o':
       {
         double ang_step = M_PI / 5;

         glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
         for (double ang = 0; ang < (2*M_PI); ang += ang_step)
           glVertex2d (sz*cos (ang)/2, sz*sin (ang)/2);
         glEnd ();
       }

As you can see the decagon is hardcoded. AFAIK there is no "draw circle"
command in OpenGL so the only way to get a smoother circle would be to
increase the numer of segments.

I'm surprised there is no type of primitive for arcs in OpenGL (or its
utility library GLU) so that hardware/CPU optimization on graphics card
drivers could be used.

Yes, it is surprising since it is an important basic shape.  However, try
Google for "draw circle OpenGL" and you will find that everyone is
constructing circles from line segments.


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.

--Rik

FWIW, your mention of using only multiplications and additions reminded me of the algorithm that I've been using since 1985, from Van Aken (1984) (http://dx.doi.org/10.1109/MCG.1984.275994). It uses only additions.

- Robert



reply via email to

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