# Tag Info

## Hot answers tagged pstricks

16

Robert Sedgewick's Algorithms in C has a whole chapter on convex hulls; here is the algorithm that he calls "package wrapping" implemented in Metapost. prologues := 3; outputtemplate := "%j%c.eps"; % following Sedgwick, "Algorithms in C", p.364 % make the first M points the hull of the first N points vardef wrap(expr N) = save theta, eta, tx, ty, ...

15

I implemented a convex hull generator in asymptote a while back. It uses the gift wrapping algorithm. As the hull is being generated, the function improves performance by eliminating points that are already inside the hull. path convexHull(pair[] in_pset) { pair[] pset = copy(in_pset); if (pset.length == 0) { path hull; return hull; } { // ...

15

Here is a TikZ kind of solution. The idea is to obtain cliped region (approximately) equal to the convex hull. For this I rotate the points (the precision is of 1°) and clip the bounding box. \documentclass[tikz,border=5]{standalone} \usetikzlibrary{calc} \tikzset{ point/.style={insert path={node[scale=3,#1]{.}}} } \newcommand\inconvexhull[2]{ ...

14

TikZ and TeX and something called Graham Scan. The macro \CH does all the stuff but the drawing. You can give it a set of coordinates with the coordinates key which will create named coordinates with the prefix ConvexHullPoint- and saves the number of the coordinate that lies on the hull in \outerPoints, all other are stored in \innerPoints: ...

13

The pst-intersect package does such calculations internally (using the Postscript procedures from http://www.math.ubc.ca/~cass/graphics/text/www/). They can be wrapped inside an own macro \convexhull as follows: \documentclass[margin=12pt,pstricks]{standalone} \usepackage{pst-intersect} \makeatletter \def\convexhull{\pst@object{convexhull}} ...

11

Here's a LaTeX3 and TikZ implementation of Graham's Scan algorithm: \documentclass[tikz]{standalone} \usepackage{xparse,l3sort} \ExplSyntaxOn \seq_new:N \g_convexhull_input_seq \seq_new:N \g_convexhull_hull_seq \int_new:N \g_convexhull_k_int \int_new:N \g_convexhull_l_int \bool_new:N \g_convexhull_stop_bool \cs_generate_variant:Nn \seq_put_right:Nn { Nf ...

11

The (original) image was created using ePiX (available from CTAN). The source sphere.xp can be compiled using elaps <options> sphere.xp to produce sphere.xp: /* -*-ePiX-*- */ #include "epix.h" using namespace ePiX; const double k(2*M_PI/(360*sqrt(3))); // assume "degrees" mode double exp_cos(double t) { return exp(k*t)*Cos(t); } double ...

8

Something like this (correcting the typo mentioned in the comments)? \documentclass[tikz, border=5pt, multi]{standalone} \usepackage{circuitikz} \usetikzlibrary{arrows.meta} \usepackage{siunitx} \begin{document} \begin{circuitikz} \draw (0,0) to[battery] (0,6.5) to[ammeter] (5.5,6.5) to[resistor] (5.5,0) (2.5,0) to[voltmeter] (2.5,6.5) ; ...

8

Using R-knitr with LaTeX to generate convex hulls. \documentclass{article} %% Reference: % https://chitchatr.wordpress.com/2011/12/30/convex-hull-around-scatter-plot-in-r/ % for the R code which is now linked to LaTeX with knitr \begin{document} <<>>= ### Plotting function to plot convex hulls ### Filename: Plot_ConvexHull.R ### Notes: ...

8

Minimal Working Solution \documentclass[pstricks,margin=1mm]{standalone} \usepackage{pst-solides3d} \psset{viewpoint=50 70 50 rtp2xyz,Decran=50,linewidth=0.5\pslinewidth} \defFunction[algebraic]{helicespherique}(t) {0.5*cos(10*t)*cos(t)} {0.5*sin(10*t)*cos(t)} {0.5*sin(t)} \begin{document} ...

8

Another late addition to the TikZ class. It defines a new plot handler so that you can use the typical TikZ syntax as you have in the question. Hence the syntax goes like \draw plot[convex hull,mark=*] coordinates {(1,1)(2,2)(1,2)(3,3)(4,2)(2,3)(3,2)}; or \draw plot[convex hull,mark=*] plot(\x,{0.05*exp(\x)}); That being said, for some reason, if I ...

7

A PSTricks solution using the pst-circ package: \documentclass{article} \usepackage{amsmath} % used for the \overset macro \usepackage{pst-circ} % used for the electrical components \begin{document} \begin{pspicture}(-1.25,0)(6.33,7) % boundry found manually \psline[arrowscale = 1.5, arrowinset = 0]{->}(0,0)(3.5,0)(3.5,3.25)(5,3.25) ...

7

The spiral can be drawn by a parameterized plot coordinate. The example uses a 3D coordinate system, the z axis is tilted 30° down. The origin is the center point of the bottom circle. The curves are drawn via plot and variable \t, which specifies the angle. The x coordinate is calculated by cos(\t)*\cylrad with \cylrad as cylinder radius. The z ...

6

The package pst-rubans draws a spiral ribbon on objects (cylinder, cone, torus, paraboloid, sphere). pst-rubans – Draw three-dimensional ribbons \documentclass{article} \usepackage{pst-rubans} \begin{document} \begin{center} \begin{pspicture}(-5,-5)(5,5) \psframe*(-5,-5)(5,5) \psset{viewpoint=50 20 40,Decran=50,resolution=720,lightsrc=viewpoint} ...

5

This is the Tikz plot: Here is a PStricks version: \documentclass{article} \usepackage{pst-plot} \begin{document} \psset{unit=0.5cm} \begin{pspicture}(12,14) \psgrid[gridcolor=red,subgridcolor=green,gridlabels=0,subgriddiv=4,gridwidth=.4pt,unit=2](0,0)(5,6) \psaxes[Dx=2,Dy=4,showorigin=false]{->}(0,0)(0,0)(11,13) \psplot{0.5}{9.5}{36 x mul ...

4

\documentclass{standalone} \usepackage{pst-solides3d} \begin{document} \psset{viewpoint=50 20 40 rtp2xyz,Decran=50,unit=0.75} \begin{pspicture}(-5,-5)(5,5) \psSolid[object=sphere,r=4,ngrid=20 20,linewidth=.1pt,linecolor=black!10, action=draw]% don't use hidden lines \defFunction[algebraic]{helix}(t)% {4*cos(3*t)*cos(t)}% ...

3

pst-solides3d and pst-3dplot can be used together but the macros use a different coordinate system. You can define an on \listplotIIID as mentioned by Alexander as: \makeatletter \def\listplotIIID{\def\pst@par{}\pst@object{listplotIIID}} \def\listplotIIID@i#1{% \@nameuse{beginplot@\psplotstyle}% \addto@pscode{% /viewpointXYZ {\pst@solides@viewpoint} def ...

3

Can also be done by \psaxes instead of \psgrid. It needs two calls of \psaxes in fact of the two different label distance. \documentclass[12pt]{exam} \usepackage{pst-all} \begin{document} \psset{unit=0.5cm} \begin{pspicture}(-1,-1)(12,14) \psaxes[Dx=2,Dy=4,showorigin=false,ticksize=0,]{->}(0,0)(11,13)% without ticks ...

3

Using the code with epix, please find a (non optimized) Asymptote version. size(10cm); import three; import graph3; import math; import solids; settings.render=0; settings.prc=false; // on se restreint à une vue 2d currentprojection=orthographic(1,2.5,3); real k=2*pi/(360*sqrt(3)); real exp_cos(real t) { return exp(k*t)*Cos(t); } real exp_sin(real ...

3

You can compile directly via pdflatex provided: 1) you add the pdf option to the document class (it says to pstricks to load auto-pst-pdf; the pstricks option isn't useful, as the package is loaded by pst-plot; 2) you enclose the pstricks code in a postscript environment (there seems to be some problems with the psgraph environment); 3) you launch pdflatex ...

3

Don't know if you are looking for something like this: \documentclass[pstricks]{standalone} \usepackage{pst-solides3d} \begin{document} \begin{pspicture}(-6,-5)(6,8) \psset{lightsrc=viewpoint,viewpoint=100 30 40 rtp2xyz,Decran=100} \psSolid[object=grille,base=-4 4 -4 4,ngrid=8](0,0,-1) ...

2

Very simply: add, say, footnotesize to your code:

2

According to the manual of pst-func, So you need to sufficiently enlarge the domain, named it exaggerated domain, in which the function to be plotted, crop the plotted graph using the original domain as the cropping box \documentclass[pstricks]{standalone} \usepackage{pst-func} \begin{document} \begin{pspicture}(-2.5,-2.5)(2.5,2.5) ...

2

You have a lot of trailing spaces which move your image to the right. If you are not sure where to place a % at the line end then do it for every line: \newcommand{\trellis}[4]{% \def \STATES {#1}% \def \PSK {#2}% \def \XDISTANCE {#3}% \def \YDISTANCE {#4}% \FPupn\NGROUPS{\STATES{} \PSK{} div 0 trunc}% ...

2

Using a more simplified example you can see it's the thmmarks option that causes the problem \documentclass[a4paper,11pt]{article} \usepackage[T1]{fontenc} \usepackage{amsmath} \usepackage %[thmmarks] {ntheorem} \numberwithin{equation}{section} \newtheorem{mydef}{Definition}[section] \begin{document} \section{First section} \begin{mydef}[Something] ...

2

According to the documentation of ntheorem, section 3.2.1, you should add the option amsmath together with thmmarks if you load the amsmath package: \usepackage[amsmath,thmmarks]{ntheorem} Full example: \documentclass[a4paper,11pt]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage{paralist} ...

1

Ok, looks like the required incantations are latex cycloid.tex dvips cycloid.dvi open cycloid.ps That opens Mac Preview, and I can manually save the PostScript file as a PDF. The final step can be automated with ps2pdf, which, I believe is part of the GhostScript distribution. or, using homebrew on the mac brew install ghostscript dvipdfm did not ...

1

With xelatex the labels are not placed as 3d objects. Looks like a bug with the xdvipdfmx driver. Hower, running latex->dvips->ps2pdf will work: \documentclass[pstricks]{standalone} \usepackage{pst-3dplot} \begin{document} %\psset{coorType=2} \begin{pspicture}(-3,-2.5)(5,5) ...

1

The reason seems to be the fact you do not have a closed curve. The documentation explains the area for the implicit plot must be greater than the area for the pspicture* environment (note the *, which will clip everything outside this area). Note it is simpler here to plot the curve as a parametric plots, since actually, \$x=y: ...

1

The TikZ version of the diagram using package pgfplots, which is based on TikZ. Then pdfTeX in PDF mode can also be used to compile the document. \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \begin{tikzpicture} \begin{axis}[ xmin=-3, xmax=6.5, ymin=-3, ymax=6.5, ...

Only top voted, non community-wiki answers of a minimum length are eligible