Archive

Archive for August, 2009

Parametric Equation of a Line

August 14, 2009 Comments off

I’m going to do one or two posts on quadratic Hermite curves and maybe extend that to splines.  One of the items in the upcoming demo is determining the vector that is twice the distance from another vector from P1 to P2.  This discussion came up elsewhere in the form of a question; given two points A and B, find the point C that is on the line from A to B at twice the distance from A to B.  I actually read the exchange after it was pretty much finished.  Lots of formulas involving distance, trig, and one based on the coordinate deltas to extend the line segment from B.

None of these are intrinsically wrong and it is always good to discuss a variety of solutions to a problem.  It is also useful to periodically back up and discuss fundamental concepts.  We are used to seeing the equation of a line in either two-point or slope-intercept form.  Given two points A and B, the parametric equation of the line is (1-t)A + tB .  This is a vector equation that yields two scalar equations, one for the x-coordinate and one for the y-coordinate and both int terms of t, i.e. x(t) and y(t).  There is another parametric form which is that of a line passing through a point and parallel to another vector, but that is another discussion for another time.  If you really want to impress people at the next Flash/Flex conference, you can say that the above equations represent a convex combination of the vectors A and B.  However, from that point onward, no one will want to talk with you 🙂

If the parameter, t is in [0,1], the resulting point is on the segment from A to B.  It is allowable for t to be outside this interval.  Values of t greater than one produce points on the line beyond B (in the direction of the vector AB).  Values of t less than zero produce points on the line beyond A in the opposite direction.

What about t = 2?  This produces the vector 2B-A.  Let dx = B.x – A.x and dy = B.y – A.y.  Let dx2 = (2B-A).x – A.x and dy2 = (2B-A).y – A.y.  Note that dx2 is 2B.x – 2A.x = 2(B.x – A.x) = 2dx.  The (Euclidean) distance from A to B is sqrt(dx*dx + dy*dy).  The distance from A to (2B-A) is sqrt(dx2*dx2 + dy2*dy2) = sqrt(4*dx*dx + 4*dy*dy) = sqrt(4(dx*dx + dy*dy)) = 2*sqrt(dx*dx + dy*dy) or twice the distance from A to B.  If you want to do even more math, you can extend this to arbitrary t-values.

There is no need to think about distances or angles.  It is possible to pre-compute the deltas and derive a formula that extends the line segment outward from B, but this involves unnecessary work and rethinking multiplier values to ‘contract’ the line segment in the other direction.  Everything you might need in this regard is already naturally present in the parametric line equation.

I know programmers can understand math, but prefer to deconstruct concepts from code, so there is a vey simple demo that goes along with this discussion.  A screenshot is shown below.

Parametric equation of a line

Parametric equation of a line

The demo starts with two points in a drawing area.  They can be dragged inside the white area, but you want to keep them relatively close to the middle of the area.  The slider represents the parameter (or t-value).  It starts at zero.  The red dot is the point on the line.  The slider ranges from -2 to 2, so you can see how values between 0 and 1 constrain the point to the line segment from A to B.  Notice the dot position when the slider is at its extreme values.

View demo

View source

It is good to periodically review basic and fundamental concepts.  I know many advanced readers will find this post boring, but if it helps at least a few people, then I think it’s worthwhile.  In the near future, we will look at how to construct a quadratic curve with two points and a tangent line.

Categories: Flex, Math

Tennis Tip: Relax For Better Passing Shots

August 12, 2009 Comments off

Everyone has a tendency to overhit (myself included), but it seems that even professionals feel a need to put some extra heat on a passing shot, which can lead to misses.  Passing shots can be difficult enough as they are most often hit on the run.  A substantial percentage of passing shots are down the line, meaning you must hit over the highest point of the net.  When margin for error is reduced, it is not good strategy to further reduce that margin by trying to hit the shot extra hard.

But, that’s not what our emotions dictate.  There is something about an opponent approaching the net that seems to require blowing the ball right past them at absolute maximum pace.  In reality, we have only one obligation and that is to win the point.  Blowing the ball past an opponent and well beyond the baseline or hitting it in the net only serves to reward the opponent for approaching in the first place.

We don’t receive any extra points for hitting the ball hard past someone.  There is an old saying that placement wins more points than power.  I’d like to add my own personal thought that a shot only needs to be as good as it needs to be, not better than it needs to be.   In other words, if I can safely slice a backhand down the line and pass someone, why try to make the shot better and hit a big topspin  backhand really hard while on the run?  Yes, it really looks impressive if I nail the shot, but what if I miss and fail to convert a break or give away the lead in a game?

All we need to do is win the point.   If you favor accuracy over power in your passing shots, then you will simply win more points.  Not only will your opponent back away from approaching the net, you can actually hit safe semi-drop shots and intentionally bring them into the net.  Use your passing shot as a winning strategy, not a defensive shot.

Now, there is one case where you might consider hitting a more powerful shot when someone approaches the net.  A lot of players are hitting approach shots down the middle of the court, even when the opponent is also near the middle.  The idea is that it is a safer shot and it forces the opponent to create an angle on the return shot which can be exploited on the following volley.

If someone approaches you in this manner, consider hitting the ball hard right back at them.  Do not create the angle they want from a middle approach.  Most 3.5 and lower players do not volley well when the ball is hit right at them.  It will be a defensive volley and open up the angle for you to position a passing shot or a lob.

When you go for the winning shot, discipline yourself to relax.  Almost every time I miss a passing shot or misplace a lob, it’s because I tensed up on the shot.  Forget about hittng the ‘big’ winner and just go for more winning shots in the first place.  You will win far more points, which could be the deciding factor in a close match.

Good luck with the game!

Categories: Tennis

Tennis Tip: Take a Snapshot Before Impact

August 10, 2009 Comments off

I often draw analogies between tennis and golf, but today’s tip comes from football.  I once heard a pro receiver say that they were coached to take a mental snapshot of catching the ball just before it arrived.  The idea was to reinforce whether it was a hands or body catch, proper body position, keeping feet in bounds, etc.  Once the mental snapshot was taken, they were supposed to duplicate the snapshot with an actual catch.

I’m just starting to hit right-handed again afer a few months layoff.  One of the early challenges is getting my timing and sense of racquet control back.   I’ve used this technique in practice in order to help reinforce proper racquet position at impact when working the ball.  I try to think of the part of the ball I want to strike as being highlighted and how I want the racquet to look at impact.  Then, I try to put the racquet in the exact position as my mental snapshot.  In order to do so, I have to have good footwork and body preparation in addition to proper racquet motion.

Take advantage of practice time by not just hitting aimlessly.  Try cross-court and down-the-line rallies.  Try to keep the ball inside the doubles alley.  Think about where you need to impact the ball and mentally higlight that part of the ball before impact.  Mental visualizations are always a bit tricky at first.  When I first tried this technique, it seemed a bit strange. After a couple practice sessions, I became comfortable with its application.  Iv’e found it helps a lot in terms of proper setup and stroke motion.  You may also find that it helps you in another important area which is focusing on the ball through impact in the first place.  Yes, we all want to look up too quickly to see where that great shot went.

Directional control based on compensations translates into inconcistent play.  Muscle memory never gets to work in your favor as the compensations are different every time you play.  Practice proper technique and then muscle memory starts to work in your favor.  Good luck with the game!

Categories: Tennis Tags: ,

Tennis Tip: A Great Use For Old Overgrips

August 7, 2009 Comments off

This tip is a modification of a suggestion given to me by my instructor.  One afternoon, he tied an old overgrip onto the top of his racquet and took some practice swings.  The idea was to show that with a smooth swing (no pauses), the overgrip should not fall towards the ground.  Same thing with the serve; no pause at the top of the motion means the overgrip should not fall (due to gravity).

I’ve mentioned before that I’m learning to play left-handed while rehabbing my right shoulder.  I thought it would be fun to learn how to serve left-handed (kind of a Luke Jensen wannabe).  I was really having trouble getting a good ‘snapping’ motion going into the ball.   One of the items I had been working on right-handed was getting more wrist motion and arm break right after impact.  Look at photos of Sampras just after impact on his serve.  The wrist has moved so much through impact that the racquet is pointing downward and this motion is supported by the arm bending at the elbow.

Now, you can naturally achieve that kind of motion by cracking a bullwhip in the air, pointing it to some imaginary point beyond the serve’s anticipated impact point.  However, I don’t want to buy an Indiana Jones bullwhip and I’d rather do drills that involve an actual tennis racquet.

I was thinking back to Tom’s tip about the overgrip, so I tried it with the service motion.  I treated the racquet as the ‘handle’ of the bullwhip and the overgrip as the actual whip.  With that mental visualization, it was easy for me (even left-handed) to get a smooth, natural snapping motion through impact.  Just try to hit some imaginary point in the air with my modified ‘bullwhip rig.’

Once I start practicing right-handed again, I’m anxious to try this drill at home and see how it translates to racquet-head speed through impact.  Mental visualizations are always tricky; what works for one person may not work for another.  It does seem, however, that I’ve found a new use for old overgrips and I am a big fan of recycling.  Hope this one might have some benefit for you.

Good luck with the game!

Categories: Tennis Tags: , ,

Degrafa Closed-Loop Catmull-Rom Spline

August 5, 2009 Comments off

Just a quick update that support for closed-loop C-R splines has been added to Degrafa.  The algorithmis is the same one as used in Singularity and is documented in this TechNote.  The algorithm is designed to provide G-1 continuity at the join and works best if the knot sequence approximately represents a closed shape.  If the outermost knots are ‘pointing away’ from each other, behavior is unpredictable.

The current implementation is targeted towards a use of defining a single knot set with closure and no further modification.  It is not possible to add knots to an already closed C-R spline.  It is not currently possible to re-open the spline after closure.  These constraints are based on discussion with designers  on most likely usage. They are subject to future modification if people come up with applications that require closure and then re-opening of the spline.

A screenshot of a simple example is shown below,

clcr

There is no need to manually duplicate the first knot – doing so would result in undesired consequences.  The MXML is simply

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
 xmlns:comp="components.*"
 xmlns:degrafa="com.degrafa.*"
 xmlns:paint="com.degrafa.paint.*"
 xmlns:geom="com.degrafa.geometry.*"
 xmlns:splines="com.degrafa.geometry.splines.*"
 layout="absolute"
 width="600" height="500"
 pageTitle="Closed Catmull-Rom Spline">

 <mx:Canvas id="background" x="50" y="90" width="500" height="320"
  backgroundColor="#FFFFFF" />

 <paint:SolidStroke id="bluestroke" weight="2" color="#0000FF"/>
 <mx:Canvas id="splineLayer" />
 <splines:CatmullRomSpline id="spline" graphicsTarget="{[splineLayer]}"
  stroke="{bluestroke}"
  knots="150,230 230,170 370,210 390,320 280,360 160,320"
  closed="true" />
</mx:Application>

Not much here and not really worth a demo. Update SVN to access the new source.

Categories: Degrafa Tags: , ,

TennisTip: Train Like a Boxer For Better Footwork

August 3, 2009 Comments off

In the previous tip, I alluded to ‘hearing’ your feet while practicing as a means to produce fewer steps and more adjujstment in setting up to hit the ball.  It’s very difficult to hit a good shot without the body being in proper position.  My biggest footwork issue is taking too few steps and getting in position early.  Instead of stepping into the ball as part of the stroke, I’m already setup, so I have to ‘muscle’ the ball with my upper body and arm.

In searching for a drill to help alleviate this tendency, I looked at other sports where the pace of action is fast and footwork is extremely important.  Martial arts in general, and boxing in particular fit the bill.  One of the old-school techniques for teaching balance and footwork in boxing is to tie a string between the boxer’s feet while standing in a ‘ready’ position.  Either through shadow-boxing or moving with a partner, the boxer must quickly move into a variety of positions without breaking the string.  This forces the boxer to make adjustments in small steps, allowing him to more quickly react to an opponent’s move in mid-step.  Not all that different from tennis; making adjustments for wind, ball spin, the ball hitting slick spots on the court, misreading a volley angle, etc.

So, I tried it … at home, of course.  Just hitting a foam ball up against a wall.  Freaking amazing drill.  What I thought was a small step broke the string instantly.  Then, I videotaped myself and saw what I was doing; trying to ‘position’ myself as quickly as possible, then hit through the ball as opposed to a single, fluid motion.  I comapred this to some video I recorded of Federer.  It’s interesting how many times his strokes have been analyzed and I never hear anyone talk about his feet.  His stroke production really begins there.

So, I continued with the drill until I could hit some really basic forehands and backhands without breaking the string.  I try to duplicate this motion when I warm up.  When doing so, I always tend to hit much better than when I warm up thiking only about stroke production in the upper body.

This is a drill that is not easy to migrate to the court, so I typically relegate it to indoor practice when it rains.  Breaking and retying a string is tedious, but don’t use a flexible cord as that could easily induce tripping.   In fact, I would recommend just practice moving into position without hitting a ball at first.   It’s a bit risky, but I found it to be an incredible drill that I can do at home.  If you don’t want to try it, at least have your local USTA pro analyze your footwork with you on video.  The bottom line is to consciously make an effort to keep the feet moving and constantly adjusting to the ball.  Always think of the stroke as starting from the ground; not the hips or the shoulders or the arm.  It’s the feet!

Good luck!

Categories: Tennis Tags: , ,