12

I want to attach a weight vector pointing downward to body of the truck. When I move the truck, the weight vector must also be automatically moved.

enter image description here

I don't know how to attach it because \pstVehicle does not provide us with such an interface. How to attach any object (in this case, a vector) to the truck?

MWE

\documentclass[border=12pt,pstricks]{standalone}
\usepackage{pst-vehicle}
\psset{unit=4cm}
\begin{document}
\begin{pspicture}(4,3)
\def\FuncA{0.5*cos(x)+1}
\psplot{0}{4}{\FuncA}
\psVehicle[vehicle=\Truck,showSlope=false]{0.2}{.7}{\FuncA}
\end{pspicture}
\end{document}
8
\documentclass[border=12pt,pstricks]{standalone}
\usepackage{pst-vehicle}
\psset{unit=4cm}
\begin{document}
\begin{pspicture}[showgrid](4,3)
\def\FuncA{0.5*cos(x)+1}
\psplot{0}{4}{\FuncA}
\psVehicle[vehicle=\Truck,showSlope=false]{0.2}{0.5}{\FuncA}
\pcline[linestyle=none](!xMTg yMTg)%
      (!xMTg mTgy 0 ge { mTgx } { mTgx neg } ifelse add yMTg mTgy abs add)
\ncput{\rnode{MP}{}}\psdot(MP)
\psline[arrowscale=2]{->}(MP)(!\psGetNodeCenter{MP}MP.x MP.y 1 sub) 
%
\psVehicle[vehicle=\Truck,showSlope=false]{0.2}{2.0}{\FuncA}
\pcline[linestyle=none](!xMTg yMTg)%
    (!xMTg mTgy 0 ge { mTgx } { mTgx neg } ifelse add yMTg mTgy abs add)
\ncput{\rnode{MP}{}}\psdot(MP)
\psline[arrowscale=2]{->}(MP)(!\psGetNodeCenter{MP}MP.x MP.y 1 sub) 
\end{pspicture}
\end{document}

enter image description here

7

I have uploaded a new version of pst-vehicle.tex (The changes should become available on the mirrors of CTAN within the next 24 hours.) that allows you to use a node with the name GravC. See the following example and test the commented-out lines.

\documentclass[border=12pt,pstricks]{standalone}
\usepackage{pst-vehicle}
\psset{unit=4cm}
\begin{document}
\begin{pspicture}[showgrid](4,3)
%\psset{GravNode=dA12 1}% Vorderradachse aber um 1 nach oben
%\psset{GravNode=0 0}% Hinterradachse
%\psset{GravNode=dA12 2 div 1}% Voreinstellung
\def\FuncA{0.5*cos(x)+1}
\psplot{0}{4}{\FuncA}
\psVehicle[vehicle=\Truck,showSlope=false]{0.2}{0.5}{\FuncA}
\psdot(GravC)
\psline[arrowscale=2]{->}(GravC)([offset=-1]GravC)
%
\psVehicle[vehicle=\Truck,showSlope=false]{0.2}{2.0}{\FuncA}
\psdot(GravC)
\psdot[linecolor=red](GravC)
\psline[arrowscale=2]{->}(GravC)([offset=-1]GravC)
\end{pspicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.