SEGCOS
f = SEGCOS (Ax, Ay, Bx, By, Cx, Cy, Dx, Dy)
Cosine of the two line segments AB and CD. Start and end of the first
line segment are given by the points (Ax,Ay)
and
(Bx, By)
. For the second line by (Cx, Cy)
and
(Dx, Dy)
.
Example 1:
' Line 1
50
Ax = 50
Ay = 50
Bx = 100
By =
' Line 2
100
Cx = 100
Cy = 50
Dx = 100
Dy =
print "SEGCOS: "; SEGCOS(Ax,Ay,Bx,By,Cx,Cy,Dx,Dy)
print "SEGSIN: "; SEGSIN(Ax,Ay,Bx,By,Cx,Cy,Dx,Dy)
print "Angle between the lines: "; deg(acos(SEGCOS(Ax,Ay,Bx,By,Cx,Cy,Dx,Dy))); "°"
Example 2
' Interactive example to illustrate the geometry
' of SEGCOS and SEGSIN
' Line 1
280
Ax = 250
Ay = 250
Bx = 200
By =
' Line 2
400
Cx = 300
Cy = 210
Dx = 300
Dy =
pen on
while(!pen(12))
cls
print "Move Mouse. Press Left Mouse Button to exit"
pen(10)
Dx = pen(11)
Dy =
SEGCOS(Ax,Ay,Bx,By,Cx,Cy,Dx,Dy)
ResultCos = SEGSIN(Ax,Ay,Bx,By,Cx,Cy,Dx,Dy)
ResultSin = print "SEGCOS between the two segments: "; ResultCos ;"
print "SEGSIN between the two segments: "; ResultSin ;"
print "Angle between the two segments : "; DEG(ACOS(ResultCos)); " DEG"
'Calc intersecton of both lines
'f1(x) = a1*x+b1
'f2(x) = a2*x+b2
'f1 = f2
'-> x0 = (b2-b1) / (a1-a2)
'-> y0 = f1(x0)
'
if( (Bx - Ax) != 0 AND (Dx - Cx) != 0) then
a1 = (By - Ay) / (Bx - Ax)
a2 = (Dy - Cy) / (Dx - Cx)
b1 = Ay - a1 * Ax
b2 = Cy - a2 * Cx
X0 = (b2-b1) / (a1-a2)
Y0 = a1*X0 + b1endif
' Draw
line X0, Y0, Ax, Ay color 2 ' Line segment 1
line X0, Y0, Cx, Cy color 2 ' Line segment 2
line Ax, Ay, Bx, By color 10 ' Line 1
line Cx, Cy, Dx, Dy color 10 ' Line 2
showpage
delay(50)
wend
Math
ABS
ABSMAX
ABSMIN
ACOS
ACOSH
ACOT
ACOTH
ACSC
ACSCH
ASEC
ASECH
ASIN
ASINH
ATAN
ATAN2
ATANH
ATN
CEIL
COS
COSH
COT
COTH
CSC
CSCH
DEG
DERIV
DETERM
DIFFEQN
EXP
EXPRSEQ
FIX
FLOOR
FRAC
INT
INTERSECT
INVERSE
LINEQN
LOG
LOG10
M3APPLY
M3IDENT
M3ROTATE
M3SCALE
M3TRANS
MAX
MIN
POLYAREA
POLYCENT
POLYEXT
POW
PTDISTLN
PTDISTSEG
PTSIGN
RAD
RND
ROOT
ROUND
SEC
SECH
SEGCOS
SEGLEN
SEGSIN
SEQ
SGN
SIN
SINH
SQR
STATMEAN
STATMEANDEV
STATMEDIAN
STATSPREADP
STATSPREADS
STATSTD
SUM
SUMSQ
TAN
TANH
TRANSPOSE
If there is insufficient information on this page and you wish learn more about SEGCOS,
please send an email to smallbasic@gmail.com. You can help to improve information about
SEGCOS by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.