Author |
Topic  |
|
kist-europe
Germany
Posts |
Posted - 12/19/2007 : 11:07:02 AM
|
Hello everyone,
I have drawn a circle with the circle tool in a graph. How can I get the X,Y coordinate data of every point in the worksheet?
Thank you! Kist-europe |
|
Mike Buess
USA
3037 Posts |
Posted - 12/19/2007 : 12:26:59 PM
|
I suspect you ultimately want the coordinates of the points inside the circle. In that case it would be easiest to upgrade to Origin 7.0 or higher and use the Cluster Tool which does everything for you. (It even draws the circle.) If that's not possible, then here is a hint. The name of the active Y dataset is saved as %C so this script types the coordinates of all points in the active curve to the script window...
get %C -e nrows; // get # points in active curve loop(ii,1,nrows) { yy = %C[ii]; // y value at row #i xx = xvalue(ii,%C); // x value at row #i type "i=$(ii), x=$(xx), y=$(yy)"; };
Mike Buess Origin WebRing Member |
 |
|
kist-europe
Germany
Posts |
Posted - 01/02/2008 : 06:56:32 AM
|
Hello,
I have upgrade the program to Origin 8.0. And I have sucessfully installed the Cluster Tool. But when I want to draw the circle in a graph, it comes out a window names 'Classic script Window'. And it seems that I should program it. It is not like the screem shot under http://www.originlab.com/FileExchange/details.aspx?fid=116 Could you please have a look at it?
Thank you |
 |
|
PeterKunhardt
USA
Posts |
Posted - 01/02/2008 : 5:05:42 PM
|
If you are looking to draw a circle on a graph and simultaneously put the values of the data points along that circle into a worksheet, there is actually an x-function designed for that specific purpose called "plotellipse." By typing "plotellipse 10 10;" in the script window, you can call Origin to create a circle centered on 0,0 with a diameter of 10. "Plotellipse 5 10;" will create an ellipse with a height of five and a width of ten.
Alternatively, you can code the x-function to have as many data points as you want with something like this:
for(i=1;i<=36;i++) { a=i*10; col(a)[i]=10*cos(a); col(b)[i]=10*sin(a); }
This code will write the values of a circle composed of 36 data points directly to a worksheet. You can create the graph from there if you need one. |
 |
|
yuivanov
USA
11 Posts |
Posted - 01/04/2008 : 2:16:46 PM
|
Hello Kist-europe If I understand your need correctly, the following OriginC code would work for you:
void GetTraceData() { PolylineGraphObject gr; // first step - get selected object gr = Selection.Objects(); if( gr ) { vector<float> vx; vector<float> vy; // get trace points in axis coordinates if( gr.GetPoints(vx, vy) > 0 ) { // create new worksheet Worksheet wks; wks.Create(); // make sure we have at least two columns in the worksheet wks.SetSize(-1,2); // finally put data in Dataset dsX(wks, 0); Dataset dsY(wks, 1); dsX = vx; dsY = vy; } } }
In order to compile this code 1. Open code builder and create som new *.cpp file (make sure that "Add to workspace" checkbox is checked) 2. Copy the code above and paste it into your file and compile it 3. Draw your circle (or freehand) and select it. 4. In the script window type "GetTraceData" and hit Enter At that time new worksheet will get created with X and Y data points points in axis units. Hope this helps. Yuri |
 |
|
greg
USA
1379 Posts |
Posted - 01/15/2008 : 11:29:36 AM
|
Here's a script that does what Yuri's C code does:
selection -g A; // grab the name of the selected line object %M=%H; // Remember this window name win -t data origin; // Create worksheet for data %N=%H; // Remember this worksheet name win -a %M; // Go back to the original window for(done=0,idx=1;done==0;idx++) { xval = %A.x$(idx); yval = %A.y$(idx); if(xval!=0/0) { %N!cell(idx,1)=xval; %N!cell(idx,2)=yval; } else done=1; }
Since LabTalk does not have a GetPoints( ) method, nor do we know how many points are in the line, I looped through points (object.x1, object.y1, object.x2, object.y2, etc.) until I stopped getting values values (xval == 0/0 == 'missing').
|
 |
|
|
Topic  |
|
|
|