LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

PlotArc accuracy and maybe a bug..?

hi im'm using PlotArc but i think there's might be a bug..

PlotArc (panel, SERIAL_GRAPH,(g_i+g_x_old-g_r), (g_j+g_r+g_y_old),(g_i+g_r+g_x_old), (g_j-g_r+g_y_old), beginangle*10, theta*10, VAL_RED,VAL_TRANSPARENT);

all variables are double.
so there is one problem with the accuracy..
how can i draw an arc with more accuracy..? is there any other way to do it without calculating all points one by one..?

and now for the bug..
even though the accuracy of tenths of degrees is not enough my draws shouldn't be to much distrote..
from the pictures below you can see there are some "inappropriate" circles..
see first screenshot..

but when i zoom just a litle bit the circles dissapears..! Why..?
see seccond screenshot..
0 Kudos
Message 1 of 8
(4,566 Views)
screenshots..
Download All
0 Kudos
Message 2 of 8
(4,565 Views)
Hello karpa,
 
I don't think there is another way to plot an arc than using this method of the enclosing rectangle built into CVI.  What do you mean by desiring a more accurate method?
 
As for the extra circle problem.  Is this error occurring with just this specific set of graph data?  Are you zooming using the default graph operations?  Could you provide a small piece of example code that exhibits this behavior?  Since this seems to be a specific problem this sample code would be very helpful in diagnosing the problem.
John B.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 8
(4,490 Views)
there are some very fast routines that you can draw an arc but you must use "int PlotPoint (int Panel_Handle, int Control_ID,
double X_Coordinate, double Y_Coordinate,
int Point_Style, int Color);" for every point and im not very sure if this is fast..
(i'm new with cvi..) maybe plotXY can do the job..

what i mean with the precision, is that the routine PlotArc uses integer for theta and beginangle, multiplied by 10. that means that the accuracy is limited to tenths of degrees. e.g you cant draw an arc with theta=0.05' degrees..

no this error occurs with two set of graph data that i have (i have only these for now..)
i'm zooming using the build in fuction (Ctrl+LeftClick)..

this is a part of my code..
variables starting with "g_" are globals. all variables are double.
g_x_old,g_y_old are the start point. g_x,g_y is the end point. g_i,g_j is the center of the arc relative to start point. g_r is the radious.

the strange thing is that i added the if (abs(theta)>220) and a breakpoint to see where my routine is wrong but the case is never happen(!). that means that theta is always <220. so it's not normal to see those circles..

(i've also tested my graph data to other simulators and they are correct..)

case 2 : case 3 :

beginangle=atan2(-g_j,-g_i)*180/pi;
if (beginangle<=0)
beginangle=360+beginangle;
endangle=atan2(g_y-(g_j+g_y_old),g_x-(g_i+g_x_old))*180/pi;
if (endangle<=0)
endangle=360+endangle;

theta = beginangle-endangle;

if (!theta)
{theta=360;}

else if (theta<0)
{
if (g_cmd==3)
{theta=-theta;}
else
{theta=-360-theta;}
}
else
{
if (g_cmd==3)
{theta=360-theta;}
else
{theta=-theta;}
}

if (abs(theta)>220)
theta=theta;

if (g_z<0)
{
PlotArc (panel, SERIAL_GRAPH,(g_i+g_x_old-g_r), (g_j+g_r+g_y_old) ,(g_i+g_r+g_x_old), (g_j-g_r+g_y_old), beginangle*10, (theta)*10, VAL_RED,VAL_TRANSPARENT);

}
else
{
PlotArc (panel, SERIAL_GRAPH, (g_i+g_x_old-g_r),
(g_j+g_r+g_y_old), (g_i+g_r+g_x_old),
(g_j-g_r+g_y_old), beginangle*10, (theta)*10,
VAL_TRANSPARENT, VAL_TRANSPARENT);

}
// ProcessDrawEvents ();
break;
Download All
0 Kudos
Message 4 of 8
(4,479 Views)
i managed to isolate the bug to this lines..

N1 G00 X0.00 Y0.00 Z0.00
N2 G03 X51.93 Y25.98 I-378.59 J12749.12 R12754.74
N3 X68.50 Y29.69 I-19.78 J35.29 R40.46
N4 X70.15 Y30.87 I-5.21 J7.28 R8.95
N5 X70.69 Y31.40 I-4.99 J5.66 R7.55
N6 X70.96 Y31.74 I-1.85 J1.72 R2.53


it looks like that the bug is in the build-in Zooming function..

the N1 line is just for seting the values to 0..

in the N2 line we draw a very smal arc but the Rect that includes the circle (see PlotArc definition)is very big. that results in automatically zooming-out in order to include the rect into the graph. (the auto fit function should fit only the area that we draw not the hole rect containing the circle..)

in N3,N4,N5,N6 lines we draw some very small arcs also, but with smaller rect's..

so after we draw all points we must zoom in to see the "real" draw (red colour) and that is were the bug is..!
the zooming function doesn't work as expecting causing those circles..

i hope that helps.. sorry for my bad english..

the result just after the simulation.. (NoZoomCirBug.png)see the red dots..

the result after we zoom-in to see what we have drawn.. (CirBug.png)
Download All
0 Kudos
Message 5 of 8
(4,412 Views)
should i somehow report this bug somewhere else..?

and actually i'm maybe wrong..
it's not the zoom fuction it just drawn like this..
probably the very very big radious.. i'm not sure..

Message Edited by karpa on 07-02-2008 06:36 AM
0 Kudos
Message 6 of 8
(4,267 Views)
Karpa,
 
I think that you may be right in the last example that the small circles you see when its zoomed out are an approximate representation of the arcs because it is so far zoomed out.  I do think that the first example you showed seemed to have incorrect circles, that wouldn't be explained in the same manner.  I would like to test this some more since it seems that there may be a problem but it will take some effort to track down.  If you have any further information that would be appreciated but I think this might be enough to go on for now.
 
Also, you mention the fact that the graph zooms out to the size of the rectangle even if its a small arc, you may want to file a Product Suggestion to change that functionality since it seems like that it might not be the most desirable behavior in every instance.
John B.
Applications Engineer
National Instruments
0 Kudos
Message 7 of 8
(4,194 Views)

Hello Karpa and John B,

   Plot an arc using enclosing rectangle built in C++ is accuracy, i used this method. But into CVI, PlotArc has beginning angle and sweep angle are n't smooth.Also have some incorrect at start point and end point. I tested it and tried to fix it but I cann't.

Can you fix this error?

Some pics i had:

Download All
0 Kudos
Message 8 of 8
(3,808 Views)