Given this Mathematica code,
Manipulate[Graphics[Line[{{0, 0}, p}], PlotRange -> 2], {{p, {1, 1}}, Locator}]
How do I set the step distance on the locator? And if possible, constrain them?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could do something like
which would restrict the locator to a rectangular lattice with a horizontal spacing of 0.4 and a vertical spacing of 0.5. The range of the coordinates for the locator is specified by
{xmin,ymin} = {-1,-1}and{xmax, ymax} = {1,1}.If you want more flexibility, e.g. you want to restrict the position of locator to a non-rectangular lattice or to a more general set of coordinates you could do something like