The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Distance between two points
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

NielsOrigin

Germany
Posts

Posted - 08/23/2005 :  04:40:04 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi Origin-Users,

is there a more simple way to measure the distance between two screen coordinates in an origin diagram than to read out both points with the data display utility and substract them manually with a calculator? e.g., is it possible to get the lenght of a line you draw in the diagram?
As we have to read out many distances it would be a great win of productivity.

Thanks in advance!

Niels

Mike Buess

USA
3037 Posts

Posted - 08/23/2005 :  08:14:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Niels,

If you only have one line you enter this in the script window...

sqrt(line.dx^2 + line.dy^2)=;


Mike Buess
Origin WebRing Member
Go to Top of Page

greg

USA
1378 Posts

Posted - 08/23/2005 :  4:53:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This script will type out the distance between two points selected with a mouse click. It continues until you press Esc. You can change it to use Data Reader instead of the Screen Reader by changing the 2 to a 3.

phase = 0;
dotool 2;
def pointproc {
px1 = px2;
py1 = py2;
px2 = x;
py2 = y;
if(phase == 1)
{
val = sqrt((px2-px1)^2+(py2-py1)^2);
type From ($(px1),$(py1)) to ($(px2),$(py2)) is $(val);
}
phase = 1 - phase;
}
dotool -d;


Go to Top of Page

Leo_Li

China
Posts

Posted - 08/24/2005 :  10:56:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
A more flexible approach is to draw a line in the diagram and then move/resize the line to check the lenght and coordinates of start/end points. To do this:

1. Write a small segment of codes in Code Builder and compile it (see the code attached in below).
2. Draw a line in graph, and make sure its name is "Line", and right click on it to bring up "Object Control" Dialogbox.
3. In the dialog, select "Moved or Resized" for "Script, Run After", and in the script field, enter

line_length(line.x, line.y, line.dx, line.dy);

The Origin C code is here:

#include <Origin.h>
void line_length(double x, double y, double dx, double dy)
{
double x0 = x - dx/2;
double x1 = x + dx/2;
double y0 = y + dy/2;
double y1 = y - dy/2;
double length = sqrt(dx*dx + dy*dy);

static int n = 0;

n++;

printf("(%d)-----------------------------------------\n", n);
printf("x0 \t %f\n", x0);
printf("y0 \t %f\n", y0);
printf("x1 \t %f\n", x1);
printf("y1 \t %f\n", y1);
printf("length \t %f\n", length);
}


---

Leo



Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000