loading
 
distance
Anonymous
11 year
Hi.

I have two distances, x and y. As I can calculate the thrigonomic distance "a" of a triangle (a ^ 2 = x ^ 2 + y ^ 2) in VBScript?

Thanks
Steven Gentner from United States  [1446 posts] 11 year
x = GetVariable("x")
y = GetVariable("y")

a = sqrt((x*x)+(y*y))

SetVariable "a", a

or just use the distance module

http://www.roborealm.com/help/Calculate_Distance.php

STeven.
Anonymous 11 year
Thank you very much, Steven.

a = sqrt((x*x)+(y*y)) - With this calculation goes the distance in millimeters. For example, 455.67544
and
a = (sqrt((x*x)+(y*y)))/1000 - With this calculation goes the distance in meters. For example, 0.45567544

This two numbers see in screen when to active module "watch variables".

Now, how I can remove this decimal number (0.45567544) and the result is 0.4?
Steven Gentner from United States  [1446 posts] 11 year
You almost have it, using the CInt you can use

a = Cint((sqrt((x*x)+(y*y)))/100) / 10

The Cint rounds it to an integer and the last /10 gets it back to a single decimal place.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index