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
 All Forums
 Origin Forum
 Origin Forum
 Distance between two points

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
NielsOrigin Posted - 08/23/2005 : 04:40:04 AM
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
3   L A T E S T    R E P L I E S    (Newest First)
Leo_Li Posted - 08/24/2005 : 10:56:05 PM
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



greg Posted - 08/23/2005 : 4:53:41 PM
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;


Mike Buess Posted - 08/23/2005 : 08:14:58 AM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000