Subversion Repositories wimsdev

Rev

Rev 2071 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2071 zjchen 1
!goto $wims_read_parm
2
 
3
:def
4
title=Plot line
5
synonyme=line plot, plot line of implicit equation, plot line by equation
6
input=equation
7
!exit
8
 
9
:proc
10
formula=!item 1 of $formula
11
fml=!mathsubst X=x in $fml
12
fml=!mathsubst Y=y in $fml
13
eq==
14
!if $eq isin $formula
15
 f=!translate internal = to , in $formula
16
 !distribute items $f into f1,f2
17
 !if $f2=$empty or $f1=$empty
18
  error=bad_formula
19
  !exit
20
 !endif
21
 fml=$f1 - ($f2)
22
!else
23
 !if y isvarof $formula
24
  fml=$formula
25
  formula=$formula = 0
26
 !else
27
  fml=$formula - y
28
  formula=y = $formula
29
 !endif
30
!endif
31
result=!exec pari eq=$fml; a=polcoeff(eq,1,x); print(a);\
32
	b=polcoeff(eq,1,y); print(b);\
33
	c=polcoeff(polcoeff(eq,0,x),0,y); print(c);\
4761 bpr 34
	print(truncate(sqrt(a^2+b^2)));
2071 zjchen 35
result=!nonempty lines $result
36
!distribute lines $result into a,b,c,n
37
m=$[abs($c)/$n]
38
cnt=!linecnt $result
39
!ifval $cnt!=4 or $n=0 or NaN isin $m or Inf isin $m
40
 result=
41
 !exit
42
!endif
43
!if abs($a) > abs($b)
44
 px=$[$b]*t-($[$c/($a)])
45
 py=$[-($a)]*t
46
 ratio=$[abs($b)/abs($a)]
47
!else
48
 px=$[$b]*t
49
 py=$[-$a]*t-($[$c/($b)])
50
 ratio=$[abs($a)/abs($b)]
51
!endif
52
m=$[2*$m/max($ratio,0.15)^0.7]
53
!ifval $m=0
54
 m=5
55
!endif
56
!read insplot_set.proc
57
insplot_set=parametric; size $insplot_size; noborder;\
58
	arrow from -$m,0 to $m,0 lt 0;\
59
	arrow from 0,-$m to 0,$m lt 0;\
60
	xtics axis; ytics axis
61
!exit
62
 
63
:output
64
Line define by equation
65
!htmlmath $formula
66
 :
67
<p><center>
68
!insplot [-$m:$m] [-$m:$m] [-$m:$m] $px,$py notitle lt 1
69
</center>
70
!exit
71