|
![](/i/fill.gif) |
Hello,
I am making a very basic test animation of a cannon shell being fired from a
gun.
After a bit of fiddling around, I have sorted out the path of the shell, and can
do pretty much anything I want with it.
However I have not figured out how to rotate it so that it is always tangent to
it's path.
I have written another "still" scene where the path is defined by a spline, but
the
closest I could get to a tangent was this:
#declare S=1;
#declare N=80;
#declare C=0;
#declare A=45; //firing angle; in animated scene it is defined otherwise.
#declare AR=radians(A);
#declare V=100; //muzzle velocity m/sec
#declare G=10; //gravity m/sec, rounded up for simplicity
#declare Path1 = spline {
linear_spline
#while(S<=N)
#declare XV = (sin(radians(90.0)-AR)*V*C);
#declare YV = (sin(AR)*V*C-G*pow(C,2));
S/N, <XV, YV, 0>
#declare S=S+1;
#declare C=C+0.1;
#end
}
#declare Cnt=1;
#declare Max=20;
sphere_sweep {
linear_spline Max
#while(Cnt<=Max)
#declare Point = Parabola1((Cnt-1)/(Max-1));
Point, 0.5
#declare Cnt=Cnt+1;
#end
pigment { Blue }
translate x*-250
scale 1/25
}
#declare P = 0.0;
cylinder {
x*50, x*-50, 1
pigment { Green }
rotate x*(A-(2*P*A) //this rotates the cylinder depending on its position
translate Path1(P)
translate x*-250
scale 1/25
}
While this doesn't look too bad for 45 degrees, any higher or lower and the fact
that it is not tangent becomes apparent.
I have looked at math.inc, and I think that VAngle() and VRotation(), or some of
the Vector Analysis macros might be what I'm looking for, but how to get a
usable value from them is currently beyond my mathematical capabilities.
If I've made anything unnecessarily complex, which is often the case, :-(
could someone point me in the right direction?
Otherwise it looks like I'm in for some fairly complicated math.
D103
Post a reply to this message
|
![](/i/fill.gif) |