<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!--Converted with LaTeX2HTML 2002-2-1 (1.71) original version by: Nikos Drakos, CBLU, University of Leeds * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan * with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --> <HTML> <HEAD> <TITLE>7.30 Trigonometric functions plotted in graph mode</TITLE> <META NAME="description" CONTENT="7.30 Trigonometric functions plotted in graph mode"> <META NAME="keywords" CONTENT="GMT_Docs"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1"> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> <LINK REL="STYLESHEET" HREF="GMT_Docs.css"> <LINK REL="previous" HREF="node150.html"> <LINK REL="up" HREF="node121.html"> <LINK REL="next" HREF="node152.html"> </HEAD> <BODY bgcolor="#ffffff"> <!--Navigation Panel--> <A NAME="tex2html4768" HREF="node152.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html4762" HREF="node121.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html4758" HREF="node150.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html4764" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html4766" HREF="node256.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html4769" HREF="node152.html">8. Creating GMT Animations</A> <B> Up:</B> <A NAME="tex2html4763" HREF="node121.html">7. Creating GMT Graphics</A> <B> Previous:</B> <A NAME="tex2html4759" HREF="node150.html">7.29 Gridding spherical surface</A> <B> <A NAME="tex2html4765" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html4767" HREF="node256.html">Index</A></B> <BR> <BR> <!--End of Navigation Panel--> <H1><A NAME="SECTION0015300000000000000000"></A> <A NAME="24759"></A> <BR> 7.30 Trigonometric functions plotted in graph mode </H1> <P> Finally, we end with a simple mathematical illustration of sine and cosine, highlighting the it graph mode for linear projections and the new curved vectors for angles. <P> <BR CLEAR="ALL"> <HR> <BR> <PRE>#!/bin/sh # GMT EXAMPLE 30 # # Purpose: Show graph mode and math angles # GMT progs: gmtmath, psbasemap, pstext and psxy # Unix progs: echo, rm # # Draw generic x-y axes with arrows ps=example_30.ps psbasemap -R0/360/-1.25/1.75 -JX8i/6i -B90f30:,-\\312:/1g10:."Two Trigonometric Functions":WS -K \ -U"Example 30 in Cookbook" --BASEMAP_TYPE=graph --VECTOR_SHAPE=0.5 > $ps # Draw sine an cosine curves gmtmath -T0/360/0.1 T COSD = | psxy -R -J -O -K -W2p >> $ps gmtmath -T0/360/0.1 T SIND = | psxy -R -J -O -K -W2p,. --PS_LINE_CAP=round >> $ps # Indicate the x-angle = 120 degrees psxy -R -J -O -K -W0.5p,- << EOF >> $ps 120 -1.25 120 1.25 EOF pstext -R -J -O -K -Dj0.05i -N << EOF >> $ps 360 1 18 0 4 RB x = cos(@%12%a@%%) 360 0 18 0 4 RB y = sin(@%12%a@%%) 120 -1.25 14 0 4 LB 120\\312 370 -1.35 24 0 12 LT a -5 1.85 24 0 4 RT x,y EOF # Draw a circle and indicate the 0-70 degree angle echo 0 0 | psxy -R-1/1/-1/1 -Jx1.5i -O -K -X3.625i -Y2.75i -Sc2i -W1p -N >> $ps psxy -R -J -O -K -m -W1p << EOF >> $ps > x-gridline -W0.25p -1 0 1 0 > y-gridline -W0.25p 0 -1 0 1 > angle = 0 0 0 1 0 > angle = 120 0 0 -0.5 0.866025 > x-projection -W2p -0.3333 0 0 0 > y-projection -W2p -0.3333 0.57735 -0.3333 0 EOF pstext -R -J -O -K -Dj0.05i << EOF >> $ps -0.16666 0 12 0 4 CT x -0.3333 0.2888675 12 0 4 RM y 0.22 0.27 12 -30 12 CB a -0.33333 0.6 12 30 4 LB 120\\312 EOF echo 0 0 0 120 | psxy -R -J -O -Sml1i -W1p >> $ps rm -f .gmt* </PRE> <BR CLEAR="ALL"> <HR> <P> The script simply draws a graph basemap, computes sine and cosine and plots them as lines, then indicates on a circle that these quantities are simply the projections of an unit vector on the x- and y-axis, at the given angle. <P> <DIV ALIGN="CENTER"><A NAME="fig:GMT_example_30"></A><A NAME="25744"></A> <TABLE> <CAPTION ALIGN="BOTTOM"><STRONG>Figure 7.30:</STRONG> Trigonometric functions plotted in graph mode.</CAPTION> <TR><TD> <DIV ALIGN="CENTER"><IMG WIDTH="528" HEIGHT="401" ALIGN="BOTTOM" BORDER="0" SRC="img208.png" ALT="\includegraphics[scale=0.5]{scripts/example_30}"></DIV></TD></TR> </TABLE> </DIV> <P> <A NAME="24764"></A> <HR> <!--Navigation Panel--> <A NAME="tex2html4768" HREF="node152.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html4762" HREF="node121.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html4758" HREF="node150.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html4764" HREF="node1.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html4766" HREF="node256.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html4769" HREF="node152.html">8. Creating GMT Animations</A> <B> Up:</B> <A NAME="tex2html4763" HREF="node121.html">7. Creating GMT Graphics</A> <B> Previous:</B> <A NAME="tex2html4759" HREF="node150.html">7.29 Gridding spherical surface</A> <B> <A NAME="tex2html4765" HREF="node1.html">Contents</A></B> <B> <A NAME="tex2html4767" HREF="node256.html">Index</A></B> <!--End of Navigation Panel--> <ADDRESS> Paul Wessel 2010-07-14 </ADDRESS> </BODY> </HTML>