Square Root

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 31-Jan-2006 15:37:07   

Hi,

I need to use Pythagoras theorem on every row in a table. It is to determine the distance between two locations for a job search.

Is it possible to do a square root with llblgen?

Cheers, I.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 31-Jan-2006 15:50:49   

isn't it :

In algebraic terms, a2 + b2 = c2 where c is the hypotenuse while a and b are the sides of the triangle.

I'm afraid I don't get what you are trying to do ?

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 31-Jan-2006 16:10:25   

Oh yes, I can square the distance (c) and compare that. Thanks.

I was trying to square root c2 to get the actual distance between the two points but this is of course unnecessary.

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 31-Jan-2006 19:52:18   

'ExOp.Sqr' would be a nice addition. simple_smile

At the moment, my SQL is coming out as...

(([jwdata].[dbo].[tbl_UK-Postcodes].[x] - @LO19153) 
*
 ([jwdata].[dbo].[tbl_UK-Postcodes].[x] - @LO19154))
 +
 (([jwdata].[dbo].[tbl_UK-Postcodes].[y] - @LO19145)
 * 
([jwdata].[dbo].[tbl_UK-Postcodes].[y] - @LO19146))

<= @X2

So its doing each difference twice.

What would be better is...



 SQUARE ([jwdata].[dbo].[tbl_UK-Postcodes].[x] - @LO19153) 
 +
 SQUARE ([jwdata].[dbo].[tbl_UK-Postcodes].[y] - @LO19145)

<= @X2

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 01-Feb-2006 06:43:28