 
 
 
 
 
 
Re: Re: Surface Normal
- To: mathgroup at smc.vnet.net
- Subject: [mg55246] Re: [mg55198] Re: Surface Normal
- From: DrBob <drbob at bigfoot.com>
- Date: Thu, 17 Mar 2005 03:30:23 -0500 (EST)
- References: <d15s2g$9k2$1@smc.vnet.net> <200503161036.FAA23857@smc.vnet.net> <opsnqkkgzgiz9bcq@monster.ma.dl.cox.net> <4238A0B5.70600@arcor.de>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
My intention was to get something more generally applicable, and I obviously failed!
This may be useful, though:
ClearAll[normVec]
normVec[f_][u__] := Block[{vars = Table[Unique["x"], {Length@{u}}], result},
     result = Cross @@ Transpose[D[f @@ vars, {vars}]] /. Thread[vars -> {u}];
     Remove @@ vars;
     result
     ]
f[x_, y_] := {x*y, x, y};
normVec[f][2, 3]
normVec[f][u, v]
{1, -3, -2}
{1, -v, -u}
Bobby
On Wed, 16 Mar 2005 22:10:13 +0100, Peter Pein <petsie at arcor.de> wrote:
>  DrBob wrote:
>
>> This may be easier to type and remember (when f is vector valued):
>>
>> normVec[f_][u_, v_] := Cross @@ Transpose@D[f[u, v], {{u, v}}]
>>
>> Bobby
>>
>> On Wed, 16 Mar 2005 05:36:34 -0500 (EST), Peter Pein <petsie at arcor.de>
>> wrote:
>>
>>> gouqizi.lvcha at gmail.com wrote:
>>>
>>>> Hi, All:
>>>>
>>>> If I have a surface in parametric form
>>>>
>>>> For example,
>>>> x = (10 + 5cosv)cosu
>>>> y = (10 + 5cosv)sinu
>>>> z = 5sinv
>>>>
>>>> How can I quickly calculate its normal for any (u,v) by mathematica
>>>>
>>>> Rick
>>>>
>>> The same way you would do with pencil & paper:
>>>
>>> In[1]:= normVec[f_][u_,v_]:=
>>>   Cross[Derivative[1,0][f][u,v],Derivative[0,1][f][u,v]]
>>> In[2]:= f[u_,v_]:={5 Cos[u](Cos[v]+2),5 Sin[u](Cos[v]+2),5 Sin[v]};
>>> In[3]:= nv = FullSimplify[normVec[f][u, v]]
>>> Out[6]=
>>>   {25*Cos[u]*Cos[v]*(2 + Cos[v]),
>>>    25*Cos[v]*(2 + Cos[v])*Sin[u],
>>>    25*(2 + Cos[v])*Sin[v]}
>>>
>>> If you need it normalized; divide by
>>> In[4]:= absnv = Simplify[Sqrt[#1 . #1]&[nv], v \[Element] Reals]
>>> Out[4]= 25*(2 + Cos[v])
>>> or insert "(#/Sqrt[#.#])&@" (without quotes) just before "Cross" in the
>>> above definition.
>>>
>>> Peter
>>>
> More readable and easier to remember - OK. But:
>
> In[1]:=
>   yourNormVec[f_][u_, v_] := Cross @@ Transpose[D[f[u, v], {{u, v}}]]
>   myNormVec[f_][u_, v_] :=
>     Cross[Derivative[1, 0][f][u, v], Derivative[0, 1][f][u, v]]
> In[3]:=
>   f[x_, y_] := {x*y, x, y};
> In[4]:=
>   StringJoin[ToString[#1], ": ", ToString[Evaluate[#1[f][2, 3]]]] &
>     {yourNormVec, myNormVec}
> From In[4]:=
>   <<error msg omitted>>
> Out[4]=
>   "yourNormVec: Cross[D[{6, 2, 3}, {{2, 3}}]]"
>   "myNormVec: {1, -3, -2}"
>
> _This_ was the reason for using Derivative[1,0][f] instead of D[f[u,v],u].
>
> Peter
>
>
>
-- 
DrBob at bigfoot.com
- References:
- Re: Surface Normal
- From: Peter Pein <petsie@arcor.de>
 
 
- Re: Surface Normal

