Giter Club home page Giter Club logo

tikz-optics's Introduction

tikz optics

The tikz library optics is designed to easily draw optical setups with tikz. It provides shapes for lens, mirror, etc. The geometrically (in)correct computation of light rays through the setup is left to the user.

Quick start

Setup

The tikz library is contained in the file tikzlibraryoptics.code.tex. This file should be copied wherever TeX can find it, for example in your TEXMF folder. To do so, it is convenient to use the TDS-structured zip file tikz-optics.tds.zip found on the releases page. The library can then be loaded through the command \usetikzlibrary{optics} in any tex file.

Alternatively, you can directly \input it in your tex file.

Usage

Use the option use optics on a tikzpicture to enable the library. Here is a very simple example of code

\begin{tikzpicture}[use optics]
	\node[lens] at (0,0) {};
	\node[mirror] at (1cm,0) {};
\end{tikzpicture}

which produces

lens and mirror

It is easy to draw slightly more complicated setups, e.g.

QI, AC, hole, lens, screen

For more details, please see the documentation.

tikz-optics's People

Contributors

fruchart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tikz-optics's Issues

Lens: Drawing focal points always fails

Steps to reproduce:

  1. use the latest version of texlive
  2. in a tikz environment, use a lens
  3. on the lens, set draw focal points to any value (does not matter)

What happens:
I get this error message:

! Package pgfkeys Error: I do not know the key '/tikz/cross out' and I am going
 to ignore it. Perhaps you misspelled it.

What should happen:
Compile without issues.

Additional info:
According to the pgfmanual.pdf (texdoc tikz), /tikz/cross out does not exist as it is not mentioned anywhere.

Version info:
pdflatex.exe --version
pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017/W32TeX)
kpathsea version 6.2.3
Copyright 2017 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.29; using libpng 1.6.29
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 3.04

tikz-optics: 43466 (0.2.3)
pgf: 44231 (3.0.1a)

Add code to simplify intersecting paths with nodes

Currently, one has to use quite some math to intersect light rays (paths) with lenses or to make them stop at e.g. a sensor. It would be nice to have basic raytracing features such as starting light at a given position + angle and tikz-optics would propagate the ray accordingly.

dependency on tikz shapes

version: 0.2.3

minimal reproducible code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{optics}
\begin{document}
\begin{tikzpicture}[use optics]
    \node[concave mirror, draw mirror focus] {};
\end{tikzpicture}
\end{document}

generates error:

Package pgfkeys: I do not know the key '/tikz/cross out' and I am going to ignore it. Perhaps you misspelled it.

And it will be fixed by adding \usetikzlibrary{shapes}, so I suggest to change

\usetikzlibrary{shapes.misc}

to something like \usetikzlibrary{shapes, shapes.misc}

Can I send a pull request an become a contributor? ๐Ÿ˜„

Inconsistent scaling

Steps to reproduce:

  1. use the latest version of texlive
  2. in a tikz environment, use several tikz-optics nodes together with basic tikz nodes.
  3. set "scale=.5" or some other scale in tikzpicture options such as
\begin{tikzpicture}[use optics, scale=.5]
    โ€ฆ
\end{tikzpicture}

What happens:
"scale" scales distances and pure tikz nodes such as path or rectangle, but it does not "object height", "slit height", focal length distances, "generic lamp", โ€ฆ

What should happen:
tikz-optics nodes should be scaled accordingly.

Version info:
pdflatex.exe --version
pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017/W32TeX)
kpathsea version 6.2.3
Copyright 2017 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.29; using libpng 1.6.29
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 3.04

tikz-optics: 43466 (0.2.3)
pgf: 44231 (3.0.1a)

Arrow tips in lines (->-, put arrow) doesn't work at all

I know you say in the manual that these things are under development/likely to change, but at the moment they do not appear to work at all with an up-to-date TeX Live 2016 (TikZ 3.0.1a, tikz-optics v0.2.2).

For example,

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{optics}
\begin{document}
\begin{tikzpicture}[use optics]
\draw[->-={at=0.25}] (0,0) -- (1, 0);
\end{tikzpicture}
\end{document}

throws

! Undefined control sequence.
\pgfkeys@code #1\pgfeov ->\letcs 
                                 \reserved {pgfk@\pgfkeyscurrentpath /unknow...
l.9 \draw[->-={at=0.25}]
                         (0,0) -- (1, 0);
?

and with

\begin{tikzpicture}[use optics]
\draw[put arrow={at=0.25}] (0,0) -- (1, 0);
\end{tikzpicture}

(or \draw [->-] (0,0) -- (1, 0);) I get

! Package pgfkeys Error: I do not know the key '/pgf/decoration/\pgfkeyscurrent
name ' and I am going to ignore it. Perhaps you misspelled it.

See the pgfkeys package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.9 \draw[put arrow={at=0.25}] (0,0) -- (1, 0);
                                               
? 

Missing character: There is no ; in font nullfont!

Hi!

I noticed a collection of messages in the log file:
Missing character: There is no ; in font nullfont!
I'm using tikz-optics v. 0.2.3

Here is a MWE.

\usepackage{tikz}
\usetikzlibrary{optics}

\begin{document}
	\begin{tikzpicture}[use optics]
	  	\draw[->] (-3,0) -- (3,0) node[anchor=north] {Axe optique};
	  	\node[thick,lens,object height=2cm] (L1) at (0,0) {};
	  	\draw (0,0) node[anchor=south west] {O};
	  	\draw[->-={at=.25},->-={at=.75}]  (-2.8, 1) -- (2.8,-1);
	  	\draw[->>-={at=.25},->>-={at=.75}] (-1.5,-1) -- (1.5, 1);
	  \end{tikzpicture}\vspace{-.8\baselineskip}\\
\end{document}

Thanks for this very useful package!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.