Graphics, Figures & Tablestikz rotate shape under coordinate transform

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
CoolnessItself
Posts: 47
Joined: Wed Nov 11, 2009 9:30 pm

tikz rotate shape under coordinate transform

Post by CoolnessItself »

Hi all,

I'm trying to draw an ellipse on a grid with perspective. If the ellipse is straight (either elongated vertically or horizontally) the below code works. But I'd like to specify a rotation (see second to last line = \ellipse{2,2}{1cm}{2cm}{0})

Code: Select all

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,shapes,calc,decorations.markings,patterns}

\begin{document}

\newcommand{\referencePoint}[1]
{
\begin{scope}
    \pgftransformcm{1}{0}{0.4}{0.5}{\pgfpoint{0cm}{0cm}}
   \filldraw[fill=red, draw=black!50] (#1) circle (.1cm);
\end{scope}
}

\newcommand{\ellipse}[4]
{
    \pgftransformcm{1}{0}{0.4}{0.5}{\pgfpoint{0cm}{0cm}}
%here I want to plot an ellipse with radii #2 and #3 at point #1, rotated by #4
\draw [rotate=#4,color=black] (#1) ellipse (#2 and #3);
}

\begin{tikzpicture}
	\begin{scope}
	     \pgftransformcm{1}{0}{0.4}{0.5}{\pgfpoint{0cm}{0cm}}
	      \draw [black!50,step=1cm] grid (8,8);
	\end{scope}
	\referencePoint{2,2}
	\ellipse{2,2}{1cm}{2cm}{0}  %<---- change rotation (0) to say, 30.
\end{tikzpicture}

\end{document}
Is this possible?

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

CoolnessItself
Posts: 47
Joined: Wed Nov 11, 2009 9:30 pm

Re: tikz rotate shape under coordinate transform

Post by CoolnessItself »

Or perhaps I should ask if there's a preferred way of dealing with perspective/3D - maybe [yslant=...]?
Post Reply