Page 1 of 1 1
Topic Options
#75915 - 2003-07-16 08:07 PM Linear Interpolation
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Playing around with the following code and get two results.

In Excel - 53
In KiXtart - 50

Here is the code:
code:
CLS
BREAK ON
;Y0 + (X - X0) * (Y1 - Y0) / (X1 - X0)
; x y
;X0 1 35
;X 4
;X1 7 62
;What is Y?

$XO=1
$X=4
$X1=7
$Y0=35
$Y1=62

$INT=$Y0 + ($X - $X0) * ($Y1 - $Y0) / ($X1 - $X0)
?$INT

GET $

I have added parenthesis too and it does not change the result.

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#75916 - 2003-07-16 08:17 PM Re: Linear Interpolation
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Convert the numbers to CDBL and test again.
_________________________
There are two types of vessels, submarines and targets.

Top
#75917 - 2003-07-16 08:18 PM Re: Linear Interpolation
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You seem to mixing "O" and "0" in your variable names.

$XO=1

35 + (4 - $X0) * (62 - 35) / (7 - $X0)

[ 16. July 2003, 20:19: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#75918 - 2003-07-16 09:21 PM Re: Linear Interpolation
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Damn, hate when that happens... they're so close to each other on the kbd. The computer should be smart enough to recognize the intent. [Big Grin]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#75919 - 2003-07-16 09:23 PM Re: Linear Interpolation
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
This would not have happened with SETOPTION('Explicit','on') [Big Grin] [Big Grin]
_________________________
There are two types of vessels, submarines and targets.

Top
#75920 - 2003-07-16 10:21 PM Re: Linear Interpolation
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
CDBL = 48.5
Otherwise, 48.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#75921 - 2003-07-16 10:32 PM Re: Linear Interpolation
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
My calculator says 48.5.
_________________________
There are two types of vessels, submarines and targets.

Top
#75922 - 2003-07-16 10:47 PM Re: Linear Interpolation
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
my calc says 48 as it is int-calculation. [Razz]
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1680 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.126 seconds in which 0.083 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org