Something not entirely intuitive to try,...stretch the muscles on the front of the thighs. Kneel on one knee and stretch/glide forward, keeping the back straight. You'll feel how to do it as you experiment and find what movement stretches the muscles on the front of the thighs. Then switch knees.
The idea is that our standing is a balancing act and often its the counter-balancing muscles as well as the muscles directly felt to be in pain that cause the spasms.