Page 1 of 2 12>
Topic Options
#72830 - 2003-02-02 11:18 PM Need math/geometry help.
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
given a line with coordinates x1:y1 to x2:y2

I need a way to find the coordinates at some point at any given percent of the length

 -

for example,

$segment=drawpercent($fromx,$fromy,$tox,$toy,50)
$segx=$segment[0]
$segy=$segment[1]

TIA

[ 03. February 2003, 01:04: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#72831 - 2003-02-03 12:10 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh, I understand percent and I understand coordinates, but your code makes my head fuzzy...

could you explain little more what you want, please, thanks.
_________________________
!

download KiXnet

Top
#72832 - 2003-02-03 01:08 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, this should do:

function splitPoint($xb,$yb,$xe,$ye,$p)
$splitPoint=($xe-$xb)*$p/100+$xb,($ye-$yb)*$p/100+$yb
endfunction

_________________________
!

download KiXnet

Top
#72833 - 2003-02-03 04:41 AM Re: Need math/geometry help.
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
ok... that worked perfectly. Thanks

Pt. 2. This should be a bit harder...

given a point, and a length, and a 360 degree direction find the point.

$point=angleline($x,$y,$radius,$angle)
$nextx=$point[0]
$nexty=$point[1]

 -
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#72834 - 2003-02-03 04:50 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
once again...
well, now you have the pic there already, but...

you mean what is that $x and $y in your picture?
_________________________
!

download KiXnet

Top
#72835 - 2003-02-03 04:53 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
or am I again trying to think it too hard...

is all that you want the coordinate of the destination in specified distance at specified direction?
_________________________
!

download KiXnet

Top
#72836 - 2003-02-03 04:56 AM Re: Need math/geometry help.
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
any X,Y coordinate on the screen/image map... positive integer

Yep from a given point, in a given 0-359 degree angle, at a specified distance. find the x,y coordinates at that point
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#72837 - 2003-02-03 05:00 AM Re: Need math/geometry help.
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
the angles can be any number between 0-359 or is it more granular, like increments of 10 degrees ?
Top
#72838 - 2003-02-03 05:09 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, do you have cos() or sin() for me?
_________________________
!

download KiXnet

Top
#72839 - 2003-02-03 05:27 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
was crashing my head when realized that you said they are positives...

might not even need pure cos... I'm coding something in my head... not sure how well does it work...
_________________________
!

download KiXnet

Top
#72840 - 2003-02-03 05:54 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, needed some tan and cos and such...
well, made them up.

then realized that kix does not have even square root calc!

or has it?
_________________________
!

download KiXnet

Top
#72841 - 2003-02-03 06:23 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, thanks to our buddy bryce, we have SQRT()

now just using it in my code...
_________________________
!

download KiXnet

Top
#72842 - 2003-02-03 09:37 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
not tested this is...
at least tested the sides code... a little.

check out does it work or not...
no external dependencies.

function coord($x,$y,$dist,$deg)
dim $
select case $deg=0 $coord=$x,$y+$dist
case $deg=90 $coord=$x+$dist,$y
case $deg=180 $coord=$x,$y-$dist
case $deg=270 $coord=$x-$dist,$y
case $deg<90 $=sides($dist,$deg) $coord=$x+$[1],$y+$[0]
case $deg<180 $=sides($dist,$deg-90) $coord=$x+$[0],$y-$[1]
case $deg<270 $=sides($dist,$deg-180) $coord=$x-$[1],$y-$[0]
case 1 $=sides($dist,$deg-270) $coord=$x-$[0],$y+$[1]
endfunction

function sides($1,$2)
dim $,$3
$1=0.0+$1*$1
$3=90.0-$2
do $=0.01+$ until $1<($*$2)*($*$2)+($*$3)*($*$3)
$sides=$*$3,$*$2
endfunction



{edit}
updated code.

[ 04. February 2003, 06:50: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#72843 - 2003-02-03 10:19 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
as a btw...
what bigger the distance is that better should the accuracy be but also that longer it should execute...

not sure, should I make it return in some percentage accuracy?
_________________________
!

download KiXnet

Top
#72844 - 2003-02-03 07:26 PM Re: Need math/geometry help.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
hey!! what is this complex math stuff!!! because everyone knows, kixtart is just a logon script language.... [Roll Eyes]

i knew that someone would find a use for the sqrt () Function [Big Grin]

Top
#72845 - 2003-02-04 05:37 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
bryce, had to skip it [Frown]
it probably is the reason why my script does not perfectly work...
or floating points overlapping...

this seems to be harder task than I quessed...
_________________________
!

download KiXnet

Top
#72846 - 2003-02-04 06:48 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, found the minor problem in there...
fixed code above.

for those who might even care, my own made sin/cos function had a failure in it.
_________________________
!

download KiXnet

Top
#72847 - 2003-02-04 08:20 AM Re: Need math/geometry help.
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Can't help Lonkero.. not too good at that math.

Seems IE 3.0 keeps giving me error.

Microsoft JScript runtime error
In frame: msncomv8
[Line: 108] get Cookie is undefined

I guess IE 3.0 does not like the KiXtart chocolate chip cookies.

Top
#72848 - 2003-02-04 10:16 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
IE?
eh, wrong topic?

and Jscript?
_________________________
!

download KiXnet

Top
#72849 - 2003-02-05 12:03 AM Re: Need math/geometry help.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
for someone wanting to try that func...

just try this script (simple as possible):
code:
for $=0 to 350 step 10
$a=coord(11,11,10,$)
at($a[1],$a[0])
"."
next

_________________________
!

download KiXnet

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 858 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.071 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

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