Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the formula for pos.distance? How can it always be below or equal to 1? #60

Closed
dglaude opened this issue Jun 5, 2017 · 1 comment

Comments

@dglaude
Copy link

dglaude commented Jun 5, 2017

I was worry about the value of pos.distance when the finger is outside of the circle.
Mostly because I use it for saturation in my colour picker.

So I added some print debug:
print(pos.x,pos.y,pos.distance)

And I get "1 1 1" as one of the possible value.
Obviously distance is not equal to sqrt(x^2+y^2)

I believe the documentation should be updated on this topic.
Anything above 1.0 seems to be rounded to 1.0.

@martinohanlon
Copy link
Owner

martinohanlon commented Jun 5, 2017

The formula is really simple, its the hypot of x,y - it is however, as you have said clamped to 1 - this being the radius of the dot.

https://github.com/martinohanlon/BlueDot/blob/master/bluedot/dot.py#L64

It was originally not clamped, but a number of people raised issues that it was confusing to have a distance > 1 returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants