-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Added Mirror Formulae Equation #9717
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
Changes from 2 commits
3abb0b4
bc1942a
acc30f0
def94b6
d0979d3
22f8647
e5f2d76
0ed896b
987068a
87cc27c
94b630c
8affc05
e250ede
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,13 +57,13 @@ | |
|
||
""" | ||
|
||
|
||
from math import isclose | ||
def focal_length(distance_of_object: float, distance_of_image: float) -> float: | ||
""" | ||
>>> focal_length(10, 20) | ||
6.666666666666667 | ||
>>> focal_length(9.5, 6.7) | ||
3.929012346 | ||
>>> isclose(focal_length(10, 20), 6.666666666666667) | ||
True | ||
>>> isclose(focal_length(9.5, 6.7), 3.929012346) | ||
True | ||
>>> focal_length(0, 20) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Traceback (most recent call last): | ||
... | ||
|
@@ -81,10 +81,10 @@ def focal_length(distance_of_object: float, distance_of_image: float) -> float: | |
|
||
def object_distance(focal_length: float, distance_of_image: float) -> float: | ||
""" | ||
>>> object_distance(30, 20) | ||
-60 | ||
>>> object_distance(10.5, 11.7) | ||
102.375 | ||
>>> isclose(object_distance(30, 20), -60.0) | ||
True | ||
>>> isclose(object_distance(10.5, 11.7), 102.375) | ||
True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. We need is_close() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there anything else I should add/change ?, or just have to wait till PR is merged ? |
||
>>> object_distance(90, 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Traceback (most recent call last): | ||
... | ||
|
@@ -100,12 +100,12 @@ def object_distance(focal_length: float, distance_of_image: float) -> float: | |
return object_distance | ||
|
||
|
||
def image_distance(distance_of_object: float, focal_length: float) -> float: | ||
def image_distance(focal_length: float, distance_of_object: float) -> float: | ||
""" | ||
>>> image_distance(10, 40) | ||
13.33333333 | ||
>>> image_distance(1.5, 6.7) | ||
1.932692308 | ||
>>> isclose(image_distance(10, 40), 13.33333333) | ||
True | ||
>>> isclose(image_distance(1.5, 6.7), 1.932692308) | ||
True | ||
>>> image_distance(0, 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Traceback (most recent call last): | ||
... | ||
|
@@ -117,5 +117,5 @@ def image_distance(distance_of_object: float, focal_length: float) -> float: | |
raise ValueError( | ||
"Invalid inputs. Enter non zero values with respect to the sign convention." | ||
) | ||
image_distance = 1 / ((1 / focal_length) + (1 / distance_of_object)) | ||
image_distance = 1 / ((1 / focal_length) - (1 / distance_of_object)) | ||
return image_distance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this import into the doctest so that the linter does not get confused.