[pstricks] tangent and orthogonal line

azzam.hassan at voila.fr azzam.hassan at voila.fr
Mon Apr 6 13:51:49 CEST 2009


Hello 
For me it worws perfectly(on miktex2.7), may be you have to delete the spaces between line (if you have copy/paste from the mail of Herbert)
Thanks Herbert  





> Message du 06/04/09 à 08h54
> De : "Herbert Voss" 
> A : "Graphics with PSTricks" 
> Copie à : 
> Objet : [pstricks] tangent and orthogonal line
> 
> 
> Hi all,
> I played a bit with tangent and orthogonal lines of a curve
> given by several points and not a function. The following
> example can draw a tangent or an othogonal line to a curve
> defined by three points. Parameters are the coordinates of
> the three points, the x value, and dx
> 
> If it may be useful, we can put it into one of the packages.
> 
> Herbert
> 
> 
> \documentclass{minimal}
> \usepackage{pst-3dplot}% for the linear equation system solver
> \makeatletter
> \def\psOrthLine{\pst at object{psOrthLine}}
> \def\psOrthLine at i(#1,#2)(#3,#4)(#5,#6)#7#8{%
> \begin at OpenObj%
> \addto at pscode{
> [[#1 dup dup mul exch 1 #2]
> [#3 dup dup mul exch 1 #4]
> [#5 dup dup mul exch 1 #6]]
> tx at 3DPlotDict begin SolveLinEqSystem end %
> /abc ED % save the solution as array
> abc aload pop % a b c on stack
> exch #7 % a c b x
> mul add exch % c+b*x a
> #7 dup mul mul add % a*x^2+b*x+c
> /y0 ED % save value
> abc aload pop pop exch % b a
> #7 mul 2 mul add % b+2*a*x0
> neg 1 exch div % mOrth
> #8 mul /dy ED % mOrth*dx
> [
> #7 #8 add y0 dy add \tx at ScreenCoor % x0+dx y0 +dy
> #7 y0 \tx at ScreenCoor % x0 y0
> /Lineto /lineto load def
> \ifshowpoints true \else false \fi
> \tx at setlinejoin % 0 1 or 2 %
> \tx at Line }% % load the pro function
> \end at OpenObj\ignorespaces}
> \def\psTangentLine{\pst at object{psTangentLine}}
> \def\psTangentLine at i(#1,#2)(#3,#4)(#5,#6)#7#8{%
> \begin at OpenObj%
> \addto at pscode{
> [[#1 dup dup mul exch 1 #2]
> [#3 dup dup mul exch 1 #4]
> [#5 dup dup mul exch 1 #6]]
> tx at 3DPlotDict begin SolveLinEqSystem end
> /abc ED
> abc aload pop % a b c on stack
> exch #7 % a c b x
> mul add exch % c+b*x a
> #7 dup mul mul add /y0 ED
> abc aload pop pop exch % b a
> #7 mul 2 mul add % b+2*a*x0=mTan
> dup % mTan mTan
> #8 mul /dy1 ED % mTan*dx
> #8 neg mul /dy2 ED % mTan*-dx
> [
> #7 #8 add y0 dy1 add \tx at ScreenCoor % x0+dx y0 +dy1
> #7 #8 sub y0 dy2 add \tx at ScreenCoor % x0-dx y0 +dy2
> /Lineto /lineto load def
> \ifshowpoints true \else false \fi
> \tx at setlinejoin %
> \tx at Line }%
> \end at OpenObj\ignorespaces}
> \makeatother
> \begin{document}
> 
> \psset{unit=2}
> \begin{pspicture}[showgrid=true](1,-1)(4,1)
> \pscurve[showpoints=true](2.1,-0.2)(2.5,0.2)(3.2,0.235)(3.8,-0.2)
> \psOrthLine[arrows=->,linecolor=red](2.5,0.2)(3.2,0.235)(3.8,-0.2){3}{0.1}
> 
> \psTangentLine[arrows=<->,linecolor=blue](2.5,0.2)(3.2,0.235)(3.8,-0.2){3}{0.5}
> \end{pspicture}
> 
> \end{document}
> _______________________________________________
> PSTricks mailing list
> PSTricks at tug.org
> http://tug.org/mailman/listinfo/pstricks
> 
> 



Cordialement
Azzam HASSAN
tel : 06 63 82 97 09

____________________________________________________

Avez-vous vu le nouveau Voila ? http://www.voila.fr 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20090406/382d8b0c/attachment.html 


More information about the PSTricks mailing list