The following code uses the rotation by \psrotate
In this way you can specify the rotation point.
% !TEX program = arara
% !TEX encoding = utf8
% !TEX spellcheck = en_GB
%: Start Header
% arara: latex: {synctex: true}
% arara: dvips
% arara: ps2pdf
\documentclass{article}
\usepackage{pstricks-add}
\def\block{%
\psaxes[ticks=none,labels=none,linestyle=dashed]{->}(0,0)(-2,-2)(2,2)[$x$,0][$y$,90]
\psframe*[linecolor=gray,opacity=0.5](-1,-0.5)(1,0.5)
\psdots[linecolor=red](0,-0.5)
\psline{->}(1.5;-45)
\uput[-45]{45}(1.5;-45){$\vec{w}$}
}
\begin{document}
\begin{pspicture}[showgrid=bottom](-3,-9)(6,2)
\rput(1,-3.5){\psrotate(0,-.5){-45}{\block}}
\pspolygon(-1,-2)(5,-8)(-1,-2|5,-8)
\psdots[linecolor=blue](1,-4)
\end{pspicture}
\end{document}
You can use the features of the calc
library for both problems. For 1., define the second coordinate as \coordinate (c2) at ($(c1)!2*2.365 cm!(dd)$);
, i.e. the point that is twice the radius away from c1
, towards dd
.
For the second you can use the let
syntax to calculate the distance from dd
to each of the circle centers, and use that as the angle radius
, and to define the center points of the two circles on the horizontal line.
I also added a second possible method for making the circles, by using node
s with an appropriate anchor
set.
Small note: I wouldn't use \node {$\bullet$}
in the circle centers, as that is positioned a bit wrong. I used a filled, circular node instead, another option would be e.g. \fill (c1) circle[radius=2pt];
\documentclass[12pt,a4paper]{scrartcl} %%KOMA class
\setkomafont{sectioning}{\rmfamily\bfseries\boldmath} %%
\usepackage{tikz}
\usetikzlibrary{rulercompass}
\usetikzlibrary{intersections,quotes,angles}
\usetikzlibrary{calc}
\tikzset{bullet/.style={circle,inner sep=0pt,minimum size=4pt,fill,draw}}
\begin{document}
\begin{tikzpicture}
\draw [color=black!5] (0,0) grid (14,10);
\draw (14,0) coordinate (a) node[right, below] {$x$}
-- (0,0) coordinate (b) node[left] {(0,0)}
-- (0,10) coordinate (c) node[left] {$y$};
\draw [->, ultra thick] (0,2) coordinate (ad) node[left] {(0,2)} -- (30:15cm) coordinate (dd) node[above] {$l$};
\path (ad) -- (dd) coordinate[pos=0.355](c1);
\coordinate (c2) at ($(c1)!2*2.365 cm!(dd)$);
%circle A
\draw [fill=red!15] (c1) circle [radius=2.365];
%circle B
\draw [fill=green!15] (c2) circle [radius=2.365];
\path
let
\p1=(ad),\p2=(c1),\p3=(c2),\n1={veclen(\x2-\x1,\y2-\y1)},\n2={veclen(\x3-\x1,\y3-\y1)}
in
(ad) ++(\n1,0) coordinate (c1n)
(ad) ++(\n2,0) coordinate (c2n);
\draw [fill=red!15] (c1n) circle [radius=2.365];
%circle B
\draw [fill=green!15] (c2n) circle [radius=2.365];
\draw (ad) -- (14,2) coordinate (l);
% draw angles
\draw
let
\p1=(ad),\p2=(c1),\p3=(c2),\n1={veclen(\x2-\x1,\y2-\y1)},\n2={veclen(\x3-\x1,\y3-\y1)}
in
(ad) -- (c1) node[bullet]{} -- (c2) node[bullet] {}--(dd)
pic["$\alpha$", draw=red, <<-, angle eccentricity=1.05, angle radius=\n1]{angle=l--ad--dd}
pic["$\alpha$", draw=red, <<-, angle eccentricity=1.02, angle radius=\n2]{angle=l--ad--dd};
\end{tikzpicture}
\begin{tikzpicture}[
declare function={
alpha=25; % angle
R=2.365cm; % radius
L=14cm; % length of ray
circpos=0.5; % position of circle tangent along ray
},
mycirc/.style={
circle,
draw=black,
thin,
fill=#1,
minimum size=R*2,
outer sep=0pt,
label={[bullet]center:}
}
]
\draw [color=black!5] (0,0) grid (L,10);
\draw (L,0) coordinate (a) node[right, below] {$x$}
-- (0,0) coordinate (b) node[left] {(0,0)}
-- (0,10) coordinate (c) node[left] {$y$};
\draw [->, ultra thick] (0,2) coordinate (ad) node[left] {(0,2)} -- ++(alpha:L) coordinate (dd)
node[above] {$l$}
node[mycirc=red!15,anchor=alpha,pos=circpos] (c1) {}
node[mycirc=green!15,anchor=alpha+180,pos=circpos] (c2) {};
% draw second set of circles
\path (ad) -- ++(0:L)
node[mycirc=red!15,anchor=0,pos=circpos] {}
node[mycirc=green!15,anchor=180,pos=circpos] {};
\draw (ad) -- (L,2) coordinate (l);
\draw (c1.alpha+180) -- (c2.alpha);
\draw
let
\p1=(ad),\p2=(c1.center),\p3=(c2.center),\n1={veclen(\x2-\x1,\y2-\y1)},\n2={veclen(\x3-\x1,\y3-\y1)}
in
pic["$\alpha$", draw=red, <<-, angle eccentricity=1.05, angle radius=\n1]{angle=l--ad--dd}
pic["$\alpha$", draw=red, <<-, angle eccentricity=1.02, angle radius=\n2]{angle=l--ad--dd};\end{tikzpicture}
\end{document}
Best Answer
Use
instead of the rotated polygon. By the way, there is a package
pst-optic
with\psprism
. See pages 21ff of the documentation.