animation based on math in PP

G

Guest

Is it possible to make an animation based on a math equation for a curve in
Power Point?

Suppose we have a horizontal rectangle. We have points A(x1,y1) on the left
and B(x2,y1) on the right side of the rectangle. Can we connect points A and
B with a curve given by a function, say of the type
y=a*sin(g*x(t)) + b*cos(h*x(t))
(where a, b, g, and h are constants and t is a variable to be incremented in
a loop) and fill the upper and lower parts (above and below the curve) with
different colors?

In another words:

(question 1) can draw a curve following a math formula and

(question 2) if so, will the curve close a shape formed by a part of the
rectangle and the curve such that the upper and lower parts of the rectangle
could be filled with different colors.

Finally, the most important (question 3): is it possible that a piece of
code incrementing t and updating the shape is executed, such that an
animation is created with the line oscillating in the slide show mode?

I feel competent with the math involved and am somehow familiar with VBA. My
questions are if things like that are possible in PP and if so, where should
I look for more info. If anybody could direct me to a book, web site or
whatever, I will appreciate it very much.

Thanks,
 
D

David M. Marcovitz

If you can calculate it, VBA can do it, but I doubt it is going to be
easy. You might want to explore something like AddCurve as in:

ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddCurve

to add a curve to the current slide. It will need some an array of points
to draw the curve (calculated by your advanced mathematical formulas).
Once it is in place, it can be filled.

For question 3, you could have some code that loops and adds a curve,
waits a short time, deletes the curve, and adds another. This might do
what you want.

--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
G

Guest

Thanks David,

I will check it out. Do you by a chance know if the varArr in
AddCurve(varArr) is to be defined as varArr(1 to 2, 1 to 151) or varArr(1 to
151, 1 to 2), assuming 50 Bezier segments on the curve?

Thanks again, JanAdam

PS. any other ideas anybody?
 
D

David M. Marcovitz

Sorry, I don't know. For AddCurve, my knowledge is no more extensive than
what is in the Help (just type AddCurve into the VBA Editor Help, and
you'll get something). This seems very specialized, so I wouldn't assume
that anyone in this group has done this before, but I'm hoping someone
more knowledgeable pipes in with a good answer to all your questions.
--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
S

Steve Rindsberg

Thanks David,

I will check it out. Do you by a chance know if the varArr in
AddCurve(varArr) is to be defined as varArr(1 to 2, 1 to 151) or varArr(1 to
151, 1 to 2), assuming 50 Bezier segments on the curve?

The latter, it seems.

This is from PPT2000's help, sometimes more useful than later versions:

Creates a Bézier curve. Returns a Shape object that represents the new curve.

Syntax

expression.AddCurve(SafeArrayOfPoints)

expression Required. An expression that returns a Shapes object.

SafeArrayOfPoints Required Variant. An array of coordinate pairs that
specifies the vertices and control points of the curve. The first point you
specify is the starting vertex, and the next two points are control points for
the first Bézier segment. Then, for each additional segment of the curve, you
specify a vertex and two control points. The last point you specify is the
ending vertex for the curve. Note that you must always specify 3n + 1 points,
where n is the number of segments in the curve.

AddCurve Method Example

The following example adds a two-segment Bézier curve to myDocument.

Dim pts(1 To 7, 1 To 2) As Single
pts(1, 1) = 0
pts(1, 2) = 0
pts(2, 1) = 72
pts(2, 2) = 72
pts(3, 1) = 100
pts(3, 2) = 40
pts(4, 1) = 20
pts(4, 2) = 50
pts(5, 1) = 90
pts(5, 2) = 120
pts(6, 1) = 60
pts(6, 2) = 30
pts(7, 1) = 150
pts(7, 2) = 90
Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddCurve pts
 
G

Guest

Thanks Gentlemen,

I think I can make it work. I can add a curve OK and it looks I can do it in
a loop. I have to slow it down otherwise the animation is too fast. Have to
find a pause or timer function and I remember seeing one so hopefully I can
do this.

I have another problem. The curve I am adding does not divide the rectangle
into two separate shapes, or I do not know how to make it to do so. It starts
and ends on the rextangle sides to a pixel. I have thus two shapes: the
rectangle and the curve. I would like to have two different shapes the bottom
part of the rectangle to the curve and the upper part, such that I can fill
them with different colors.

Any suggestions?

JanAdam
 
S

Steve Rindsberg

Thanks Gentlemen,

I think I can make it work. I can add a curve OK and it looks I can do it in
a loop. I have to slow it down otherwise the animation is too fast. Have to
find a pause or timer function and I remember seeing one so hopefully I can
do this.

Put this in your declarations section:

Declare Sub Sleep Lib "kernel32" (ByVal lSleepTime As Long)

and then wherever you want a pause:

Sleep(1000) ' Sleep for 1000 milliseconds

I have another problem. The curve I am adding does not divide the rectangle
into two separate shapes, or I do not know how to make it to do so. It starts
and ends on the rextangle sides to a pixel. I have thus two shapes: the
rectangle and the curve. I would like to have two different shapes the bottom
part of the rectangle to the curve and the upper part, such that I can fill
them with different colors.

Are you sure this wouldn't be easier if you used a Freeform instead of a curve?
Record a macro while you draw one to get an idea where to start.
 
G

Guest

Thanks Steve again. I will try the Sleep.

To the curve: I cannot do it free hand. It is sort of a simulation and the
math behind the curve is exact.

Imagine I want to show vibrations of a string, the base tone plus some
harmonics, decaying with different time scales. Not exactly my goal but close
enough in general principle. But I can get away without the fills, although
it would be nicer to have them.

JanAdam
 
S

Steve Rindsberg

Thanks Steve again. I will try the Sleep.

To the curve: I cannot do it free hand. It is sort of a simulation and the
math behind the curve is exact.

I was suggesting that you use FreeForms instead of curves ... not that you draw
anything freehand. Why touch that nasty mouse thing when VBA can do the work for
us??? said:
Imagine I want to show vibrations of a string, the base tone plus some
harmonics, decaying with different time scales. Not exactly my goal but close
enough in general principle. But I can get away without the fills, although
it would be nicer to have them.

For that, curves, yes. But for dividing a rectangle, try the other.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top