想模拟画平抛物线(方程:y=4kx(l-x))k和l是常数。用的是最笨的方法,各位有什么好的方法,教一下小弟各位帮忙找下错误- (DEFUN C:tempxlx ()
- (SETVAR "CMDECHO" 0)
- (SETQ OLDOS (GETVAR "OSMODE"))
- (SETVAR "OSMODE" 0)
- (SETQ PTA (GETPOINT "\nFirst Point : ")
- PTB (GETPOINT PTA "\nSecond Point : ")
- VK (GETDIST "\nParameter K = ")
- VD (GETINT "\nDivide of the line : ")
- Dst (DISTANCE PTA PTB)
- Ds (/ Dst VD)
- Beta (ANGLE PTA PTB)
- ;VL (* Dst (cos Beta))
- PTAx (car PTA)
- PTAy (cadr PTB)
- PTBx (CAR PTB)
- PTBy (CADR PTB)
- VL (- PTBx PTAx)
- PTCx (- PTBx PTAx)
- PTCy (- PTBy PTAy)
- DX (/ (- PTBx PTAx) VD)
- Alpha (angle '(0 0) (list PTCx PTCy))
- TMPDST (SQRT (+ (* PTCx PTCx) (* PTCy PTCy)))
- Dstx DX
- )
- (SETQ PT1 '(0 0))
- (COMMAND "SPLINE" PTA)
- (REPEAT VD
- (SETQ PT1 (polar PT1 Beta Ds))
- (SETQ fx (* 4 VK Dstx (- VL Dstx)))
- (setq pt2 (polar pt1 (* pi 1.5) fx))
- (setq realpt (polar pt2 Alpha TEPDST))
- (setq Dstx (+ Dstx DX))
- (COMMAND realpt)
- )
- (COMMAND "" "" "")
- (SETVAR "OSMODE" OLDOS)
- (SETVAR "CMDECHO" 1)
- (PRINC)
- )
|