Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6994846

Browse files
Code review changes
1 parent81f3a23 commit6994846

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

‎doc/users/next_whats_new/3d_plot_focal_length.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ Give the 3D camera a custom focal length
33

44
Users can now better mimic real-world cameras by specifying the focal length of
55
the virtual camera in 3D plots. An increasing focal length between 1 and
6-
+infinity "flattens" the image, while a decreasing focal length between 1 and 0
6+
infinity "flattens" the image, while a decreasing focal length between 1 and 0
77
exaggerates the perspective and gives the image more apparent depth. The
88
default focal length of 1 corresponds to a Field of View (FOV) of 90 deg, and
99
is backwards-compatible with existing 3D plots.
1010

1111
The focal length can be calculated from a desired FOV via the equation:
12-
|``focal_length = 1/tan(FOV/2)``
12+
13+
..mathmpl::
14+
15+
focal\_length = 1/tan(FOV/2)
1316

1417
..plot::
1518
:include-source: true

‎examples/mplot3d/projections.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,25 @@
77
changing the focal length for a perspective projection. Note that matplotlib
88
corrects for the 'zoom' effect of changing the focal length.
99
10-
An increasing focal length between 1 and+infinity "flattens" the image, while
10+
An increasing focal length between 1 and infinity "flattens" the image, while
1111
a decreasing focal length between 1 and 0 exaggerates the perspective and gives
1212
the image more apparent depth. The default focal length of 1 corresponds to a
1313
Field of View (FOV) of 90 deg. In the limiting case, a focal length of
14-
+infinity corresponds to an orthographic projection after correction of the
14+
infinity corresponds to an orthographic projection after correction of the
1515
zoom effect.
1616
1717
You can calculate focal length from a FOV via the equation:
18-
focal_length = 1/tan(FOV/2)
18+
19+
.. mathmpl::
20+
21+
1 /\tan (FOV / 2)
1922
2023
Or vice versa:
21-
FOV = 2*atan(1/focal_length)
24+
25+
.. mathmpl::
26+
27+
FOV = 2 *\atan (1 / focal\_length)
28+
2229
"""
2330

2431
frommpl_toolkits.mplot3dimportaxes3d
@@ -36,7 +43,7 @@
3643

3744
# Set the orthographic projection.
3845
axs[0].set_proj_type('ortho')# FOV = 0 deg
39-
axs[0].set_title("'ortho'\nfocal_length =+∞",fontsize=10)
46+
axs[0].set_title("'ortho'\nfocal_length = ∞",fontsize=10)
4047

4148
# Set the perspective projections
4249
axs[1].set_proj_type('persp')# FOV = 90 deg

‎lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,22 +1046,20 @@ def set_proj_type(self, proj_type, focal_length=None):
10461046
The focal length can be computed from a desired Field Of View via
10471047
the equation: focal_length = 1/tan(FOV/2)
10481048
"""
1049+
_api.check_in_list(['persp','ortho'],proj_type=proj_type)
10491050
ifproj_type=='persp':
10501051
iffocal_lengthisNone:
10511052
self.focal_length=1
10521053
else:
10531054
iffocal_length<=0:
1054-
raiseValueError(f"focal_length ={focal_length} must be"+
1055+
raiseValueError(f"focal_length ={focal_length} must be"
10551056
" greater than 0")
10561057
self.focal_length=focal_length
10571058
elifproj_type=='ortho':
10581059
iffocal_lengthnotin (None,np.inf):
1059-
raiseValueError(f"focal_length ={focal_length} must be"+
1060+
raiseValueError(f"focal_length ={focal_length} must be"
10601061
f"None for proj_type ={proj_type}")
10611062
self.focal_length=np.inf
1062-
else:
1063-
raiseValueError(f"proj_type ={proj_type} must be in"+
1064-
f"{'persp','ortho'}")
10651063

10661064
def_roll_to_vertical(self,arr):
10671065
"""Roll arrays to match the different vertical axis."""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp