Re: Scaling a part of a composite image
- To: mathgroup at smc.vnet.net
- Subject: [mg98843] Re: Scaling a part of a composite image
- From: dh <dh at metrohm.com>
- Date: Mon, 20 Apr 2009 05:41:04 -0400 (EDT)
- References: <gs9eo8$n10$1@smc.vnet.net>
Hi Alexei, to specify your arrow, you may use a mix of coordinates and scaled coordinates like e.g.: Polygon[{pt1, Scaled[10^-2 {0, -2, -2}, pt2], Scaled[10^-2 {0, 3, 2}, pt2]}] Daniel Alexei Boulbitch wrote: > Dear community, > > In an image composed of at least two (or more) parts combined using > Show, I would like to programmatically scale one of these two images > with respect to the size of the whole composite image. > Do you know, how to do this in Mathematica 6? > > Is it possible in Mathematica 6 to determine programmatically the total size of the Image? > > To be more concrete: the function below draws a 3D trajectory - a > solution of a system of three ODE. In addition it draws a triangle > attached to the trajectory. The latter plays the role of an arrow head > showing the direction of the trajectory. Parameters in the argument > are: point is a list of initial values {x0,y0,z0} of the trajectory, > tmax is the calculation time, col is the color of both the trajectory > and the arrow head, arrpos is the time fixing the position of the arrow > on the trajectory, and arrsize scales the arrow size. The subfunction > arr defines the arrow using 2 closely-lying points taken on the trajectory. > > directedTrajectory3D[point_List, tmax_, col_, arrpos_, arrsize_] := > Module[{p0, eq4, eq5, eq6, pt1, pt2, s}, > arr[pt1_List, pt2_List] := Module[{r}, > r = (pt1 - pt2)2 /. List -> Plus // Sqrt; > Graphics3D[ {col, > Polygon[{pt1, {pt2[[1]], pt2[[2]] - 0.2*r, > pt2[[3]] - 0.2*r}, {pt2[[1]], pt2[[2]] + 0.3*r, > pt2[[3]] + 0.2*r} }]}]]; > > eq4 = x[0] == point[[1]]; > eq5 = y[0] == point[[2]]; > eq6 = z[0] == point[[3]]; > s = NDSolve[{eq1, eq2, eq3, eq4, eq5, eq6}, {x, y, z}, {t, 0, > tmax}]; > p0 = ParametricPlot3D[ > Evaluate[{x[t], y[t], z[t]} /. s], {t, 0, 30}, PlotRange -> All, > PlotStyle -> col, AxesLabel -> {"x", "y", "z"}]; > > Show[{p0, > arr[Evaluate[{x[arrpos], y[arrpos], z[arrpos]} /. s] // Flatten, > Evaluate[{x[arrpos - 0.5*arrsize], y[arrpos - 0.5*arrsize], > z[arrpos - 0.5*arrsize]}] /. s // Flatten]}] > ]; > > One can try with the example of Lorentz system from help: > > Clear[eq1, eq2, eq3]; > eq1 = > \!\(\*SuperscriptBox["x", "\[Prime]", > MultilineFunction->None]\)[t] == -3 (x[t] - y[t]); > eq2 = > \!\(\*SuperscriptBox["y", "\[Prime]", > MultilineFunction->None]\)[t] == -x[t] z[t] + 26.5 x[t] - y[t]; > eq3 = > \!\(\*SuperscriptBox["z", "\[Prime]", > MultilineFunction->None]\)[t] == x[t] y[t] - z[t]; > > directedTrajectory3D[{1, 0, 1}, 30, Red, 5, 0.1] > > > A strong drawback is that in this function one needs to rescale the > arrow sizes by hand each time. Compare two images with the same > trajectory in which the arrow is placed the first time at t=5 and then > at t=15 with the same arrsize=0.1. > > directedTrajectory3D[{1, 0, 1}, 30, Red, 5, 0.1] > directedTrajectory3D[{1, 0, 1}, 30, Red, 15, 0.1] > > I would like to find a programmatic way of scaling the arrows so that > they would be always visible and the same size. > > Thank you, Alexei >