Moebius strips

• To: mathgroup at smc.vnet.net
• Subject: [mg6543] Moebius strips
• From: wself at viking.emcmt.edu (Will Self)
• Date: Mon, 31 Mar 1997 23:01:42 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Arturus asked for code for a nice Moebius strip.  With this function you
can have it all:  nice Moebius strips and ones that are not so nice.  If you
have any curve in 3-space given as {f[t],g[t],h[t]}, this function will
give you a strip whose centerline is your curve.  You can give an integer
value for the argument twist, which will control the number of times
the strip twists around.

---------------------------------

norm[v_]:=Sqrt[v.v]

cross[{a_,b_,c_},{d_,e_,f_}]:={b f - c e, c d - a f, a e - b d}

perp[v_, unitVec_]:= v - (v . unitVec) unitVec

normalizedPerp[v_, w_]:= perp[v, w]/norm[perp[v, w]]

moebiusStrip[{f_,g_,h_},{s_,begin_,end_}, width_,twist_,options___]:=
Module[{positionVector, velocityVector, unitTangentVector,
accelerationVector, normalVector, binormalVector,
twist2=twist Pi/(end-begin)},
positionVector[t_]={f,g,h}/.s->t;
velocityVector[t_]=Derivative[1][positionVector][t];
unitTangentVector[t_]=velocityVector[t]/norm[velocityVector[t]];
accelerationVector[t_]=Derivative[2][positionVector][t];
normalVector[t_]=normalizedPerp[accelerationVector[t],unitTangentVector[t]];
binormalVector[t_]=cross[unitTangentVector[t],normalVector[t]];
ParametricPlot3D[positionVector[w]+
u*Cos[twist2 w]*normalVector[w]+
u*Sin[twist2 w]*binormalVector[w],
{w, begin, end}, {u, -width, width},
Compiled -> False, PlotPoints->{36,2}, options]]

---------------------------------

You may want to increase the 36 in the PlotPoints option.  The function
as written is *anything but* optimized for speed.  On the other hand, I
think it provides an excellent example of how you can often write
Mathematica code that is a close reflection of the mathematics you are
doing.

Example:

moebiusStrip[{Cos[t], Sin[t],.3Cos[t]}, {t, 0, 2 Pi}, 0.2, 2]

Will Self
Montana State University, Billings MT

```

• Prev by Date: Re: Bug: V.3 for PowerMac
• Next by Date: Coupled ODEs: not solving [REPOST]
• Previous by thread: Re: Bug: V.3 for PowerMac
• Next by thread: Coupled ODEs: not solving [REPOST]