Graphics, Figures & TablesPSTricks | Draw Line with relative Angle to another

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

PSTricks | Draw Line with relative Angle to another

Post by svend_tveskaeg »

Hi all.

Consider the following MWE:

Code: Select all

\documentclass{article}
\usepackage{auto-pst-pdf,pst-node}

\begin{document}

\begin{pspicture}
\pnode(0,0){A}
\pnode(4,0){B}
\psline(A)(B)
\end{pspicture}

\end{document}
I compile with

Code: Select all

pdflatex -shell-escape <filename>.tex
Now to my problem: I would like to draw a line from node A, making a 45 degrees angle with the line from node A to node B, of length 5 (or some other length --- it does not matter).

I have tried \psline(A)([angle=45]A) (and other things) but I could not figure out how to do it without having specific coordinates for the other end of the line I want do draw.

How do I do this?

Thank you in advance!
Last edited by svend_tveskaeg on Mon Oct 01, 2012 5:33 pm, edited 1 time in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

PSTricks | Draw Line with relative Angle to another

Post by CrazyHorse »

svend_tveskaeg wrote:Now to my problem: I would like to draw a line from node A, making a 45 degrees angle with the line from node A to node B, of length 5 (or some other length --- it does not matter).

I have tried \psline(A)([angle=45]A) (and other things) but I could not figure out how to do it without having specific coordinates for the other end of the line I want do draw.

How do I do this?

Code: Select all

\documentclass{article}
\usepackage{auto-pst-pdf,pstricks-add}
\begin{document}

\begin{pspicture}[showgrid](5,4)
\pnode(0,0){A}
\pnode(4,0){B}
\psline(A)(B)
\psRelLine[angle=45](A)(B){1.25}{C}
\psdot(C)
\psarc[linestyle=dashed](0,0){5}{0}{50}
\end{pspicture}

\end{document}
Attachments
xx.png
xx.png (9.46 KiB) Viewed 3434 times
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: PSTricks | Draw Line with relative Angle to another

Post by svend_tveskaeg »

Thank you, Herbert!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply