(compliments of Wikipedia.org)
Yoga can help or cause knee pain. The key is alignment. This is one of the reasons working with a knowledgeable teacher is so helpful. In general, keep the knee cap (patella) in the same direction as the middle and 2d toe. Never put weight on the knee when it is past the toes. That is, when lunging keep the shin perpendicular to the ground and the knee directly over the ankle--NOT over the toes! When standing balance the weight evenly on the 4 corners of the feet: Ball mound of the big toe, ball mound of the baby toe, inner and outer heel.
If you experience knee pain, try the following therapeutic:
Sit on the floor with legs out straight (sit on a blanket if needed to maintain a low back curve).
Place a strap around the thighs and a block between the shins.
Keep the legs going straight forward from the hips. Hug the block in with the shins and push the thighs apart against the strap: "shins in - thighs out." On an exhale slide the heels on the floor (easiest to do on a hard floor with the heels on a blanket) toward the body, keeping the shins in and thighs out.
Inhale and slowly release the legs back out.
Repeat at least 6 times once or twice a day. Pay particular attention to "shins in - thighs out". If this is too hard. Place the block between the thighs to bring them out and the strap around the shins to draw them in.
How far in or out? Excellent question! The answer is "just enough to keep the hips, knees, and ankle all in a straight line."