This demonstrates the use of the fixed point calculation package fp.sty to process user-defined parameters while rendering a TikZ picture. In this example, a ellipse is rendered, representing the polarization state of light for an arbitrary x-amplitude y-amplitude, and relative phase. See http://en.wikipedia.org/wiki/Polarization for background information on polarization states of light.
In this example, a relatively simple command is called from within a tikzpicture environment:
\begin{tikzpicture}%usage: \polellipse{ E_{0x} }{ E_{0y} }{ phase }\polellipse{3}{2}{45}\end{tikzpicture}
The contents of the \polellipse command is rather lengthy, but can be broken down into two main parts. The first part performs the necessary math to convert the user-defined parameters E_{0x}, E_{0y}, and phase into values which are useful to the drawing process. The second part uses the calculated numbers to draw a coordinate axis, the ellipse, and appropriate annotation.
This example can be helpful when preparing a document describing various polarization states of light. The document can contain an arbitrary number of \polellipse commands, each with an arbitrary configuration of parameters. Each rendered figure is based on the same code, so a desired change to the style can update all figures.
This general technique can be applied to any TikZ figure, where the document calls any number of commands with some passed parameters, and some computation is be performed to render the diagrams.

Edit and compile if you like:
% Polarization state of light% Author: Jeff Hein\documentclass{article}%========%packages%========\usepackage{tikz} %tikz graphics package for drawing with pgf\usepackage[active,tightpage]{preview}\PreviewEnvironment{tikzpicture}\setlength\PreviewBorder{5pt}%\usepackage{fp} %for fixed point math\usepackage{ifthen} %for \ifthenelse{}{}{} conditional statements%===================%Style configuration%===================\pagestyle{empty}\PreviewEnvironment{tikzpicture}\setlength\PreviewBorder{2mm}\usetikzlibrary{calc}%line thickness styles: ultra thin, very thin, (thin), semithick, thick, very thick, ultra thick%line dash styles: loosely dashed, densely dashed, loosely dotted, densely dotted\tikzset{bkgd_line/.style={very thin,color=gray}}\tikzset{dashed_bkgd_line/.style={thin, dashed,color=gray}}\tikzset{dimension_line/.style={very thin,color=gray}}\tikzset{axis_line/.style={thin}}\tikzset{object_line/.style={thick}}\tikzset{textlabel/.style={color=red}}%===================%Command Definitions%===================
Click to download: polarization-state-of-light.tex • polarization-state-of-light.pdf
Open in Overleaf: polarization-state-of-light.tex