Re: spinning/rotating object with shadow
- To: mathgroup at smc.vnet.net
- Subject: [mg38965] Re: spinning/rotating object with shadow
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Thu, 23 Jan 2003 08:03:05 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <b0lvcd$5a4$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Aber bitte -- ist mir immer eine Freude. The true/ not faked animation with all shadows can be found at http://phong.informatik.uni-leipzig.de/~kuska/icosshad.mov Regards Jens Selwyn Hollis wrote: > > Danke schoen Jens! That's just what I needed. After some refinement, > here's the result as a QuickTime movie (140k): > > http://www.appliedsymbols.com/mma/icosaspin.mov > > (If WRI had the same mediocre standards as their competition, they'd > feature this on their website.. :-) > > ---- > Selwyn Hollis > > On Tuesday, January 21, 2003, at 07:39 AM, Jens-Peer Kuska wrote: > > > Hi, > > > > a) computing the true shadows of the 3 light sources > > would requite the construction of the shadow volumes > > and take an half hour per frame > > > > b) fake a single shadow is easy with > > > > Needs["Graphics`Polyhedra`"] > > Needs["Graphics`Shapes`"] > > > > toShadow[gray_?MatrixQ, {x1_, x2_}, {y1_, y2_}, z_] := > > > > Module[{n, m, dx, dy, points, cgraph}, > > {m, n} = Dimensions[gray]; > > dx = (x2 - x1)/(n); > > dy = (y2 - y1)/(m); > > points = Table[{x1 + dx*i, y1 + dy*j, z}, {j, 0, m}, {i, 0, n}]; > > > > poly = > > Drop [#, -1] & /@ > > Drop[Transpose[{points, RotateRight[points], > > RotateLeft /@ RotateRight[points], RotateLeft /@ points}, > > {3, 1, > > 2}], -1]; > > {EdgeForm[], Transpose[{Map[SurfaceColor[GrayLevel[#]] &, gray, > > {2}], > > Map[Polygon, poly, {2}]}, {3, 1, 2}]} > > > > > > ] > > > > makeShadow[t_, opts___?OptionQ] := > > Module[{sh}, > > sh = DensityPlot[ > > 1 - Exp[-(3 + Sin[t/2])*(x^2 + y^2)], {x, -2, 2}, {y, -2, 2}, > > DisplayFunction -> Identity, opts]; > > toShadow[sh[[1]], {-2, 2}, {-2, 2}, -2] > > ] > > > > > > obj = Table[RotateShape[Icosahedron[], t, t/2, t/3], {t, 0, 8, 1/10}]; > > > > MapIndexed[ > > Show[Graphics3D[{makeShadow[First[#2], PlotPoints -> 30], #1}, > > Boxed -> False, PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}]] &, > > obj]; > > > > but that is *not* the shadow that the three colored light sources would > > produce -- that would be much more expensive. > > > > If some one else would like to have (hard) shadows I can include it > > into > > MathGL3d -- just send a mail about it to me. > > > > Regards > > Jens > > > > Selwyn Hollis wrote: > >> > >> I'm interestied in using Mathematica to do something similar to this: > >> > >> http://www.mapleapps.com/powertools/logos/appess3.gif > >> > >> Does anyone have a guess at what kind of rotation is being used? > >> And how one might get a similar shadow effect? (Without resorting to a > >> different rendering engine.) > >> > >> Thanks, > >> > >> Selwyn > > > > From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com> To: mathgroup at smc.vnet.net > > To: mathgroup at smc.vnet.net > > Subject: [mg38965] , why is it not working > > > > > >> -----Original Message----- > >> From: Ashraf El Ansary [mailto:Elansary at btopenworld.com] To: mathgroup at smc.vnet.net > > To: mathgroup at smc.vnet.net > >> Sent: Saturday, January 18, 2003 6:39 AM > >> To: mathgroup at smc.vnet.net > >> Subject: [mg38965] , why is it not working > >> > >> > >> Hi all, > >> Does anyone why f@a_=2 a gives a proper answer for f[1] > >> and not in the case of Prefix[s[a_]]= 2 a eventhough that > >> Prefix[s[a_]]= > >> f@a_??? > >> > >> Thanks > >> In[1]:= > >> f@a_=2 a > >> f[1] > >> Out[1]= > >> 2 a > >> Out[2]= > >> 2 > >> In[3]:= > >> Prefix[s[a_]] > >> Prefix[s[a_]]=2 a > >> s[1] > >> Out[3]= > >> s@a_ > >> Set::write: Tag Prefix in s@a_ is Protected. > >> Out[4]= > >> 2 a > >> Out[5]= > >> s[1] > >> > >> > >> > > > > Ashraf, > > > > the question is: what behaviour did you expect? An answer to that might > > solve your problem. > > > > First, Prefix[s[a_]] is *not* the same as f@a_ > > > > In[1]:= f@a_ := 2 a > > In[2]:= ?f > > Global`f > > f[a_] := 2 a > > > > In[3]:= f[1] > > Out[3]= 2 > > > > Compare this to > > > > In[4]:= Prefix[s[a_]] > > Out[4]= s@a_ > > > > In[5]:= % // FullForm > > Out[5]//FullForm= > > Prefix[s[Pattern[a, Blank[]]]] > > > > So Prefix is a wrapper for printing purposes (only). Such you cannot > > make > > definitions for it (as it is protected), but also, it is a special > > form not > > submitted to the standard evaluation sequence, see: > > > > In[7]:= Prefix[s[aaa___]] ^= s[aaa] > > Out[7]= s[aaa] > > > > In[8]:= s[a_] := 2 a > > In[9]:= ?s > > Global`s > > Prefix[s[aaa___]] ^= s[aaa] > > s[a_] := 2 a > > > > > > In[10]:= Prefix[s[2]] > > Out[10]= Prefix[4] > > > > So even Upvalues won't work. You may however do > > > > In[12]:= Prefix[Unevaluated[s[2]]] > > Out[12]= 4 > > > > The very question, however, is whether this is what you intended, or > > say, > > what did you want to achieve at all? > > > > -- > > Hartmut Wolf > > > >