rL idZddlZddlmZ ddZdZdZdZdZ d Z d Z d Z d Z d ZdZej ddZdZdZdZy)z, Various transforms used for by the 3D code N)_apic ||z }||z }||z } ||\} } } || z}|| z}| | z} tjd|z dd| |z gdd|z d| |z gddd| z | | z ggdgS)z Produce a matrix that scales homogeneous coords in the specified ranges to [0, 1], or [0, pb_aspect[i]] if the plotbox aspect ratio is specified. r)rrrrnparray) xminxmaxyminymaxzminzmax pb_aspectdxdydzaxayazs a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mpl_toolkits/mplot3d/proj3d.pyworld_transformationr s B B B B b b b 88adqQb1AbDQb1q!B$b113 44c|tjj|z \}}}tj|}tj|}dtj|dz dzz}tj ||z|z|z||z|z||zz ||z|z||zzg||z|z||zz||z|z|z||z|z||zz g||z|z||zz ||z|z||zz||z|z|zgg}|S)zK Produce a rotation matrix for an angle in radians about a vector. )rlinalgnormsincosr) vanglevxvyvzsctRs r_rotation_about_vectorr( sRYY^^A&&JBB u A u A "&&q/1 A  2b12b2a42b2a48 2b2a42b12b2a48 2b2a42b2a42b157 8A Hrcr||z }|tjj|z }tj||}|tjj|z }tj||}|dk7r9t || }tj ||}tj ||}|||fS)a Get the unit viewing axes in data coordinates. Parameters ---------- E : 3-element numpy array The coordinates of the eye/camera. R : 3-element numpy array The coordinates of the center of the view box. V : 3-element numpy array Unit vector in the direction of the vertical axis. roll : float The roll angle in radians. Returns ------- u : 3-element numpy array Unit vector pointing towards the right of the screen. v : 3-element numpy array Unit vector pointing towards the top of the screen. w : 3-element numpy array Unit vector pointing out of the screen. r)rrrcrossr(dot)Er'VrollwurRrolls r _view_axesr21s0 QA ")).. A AA ")).. A AA qy&q4%0 FF5!  FF5!  a7Nrctjd}tjd}|||g|ddddf<| |dddf<tj||}|S)a Return the view transformation matrix. Parameters ---------- u : 3-element numpy array Unit vector pointing towards the right of the screen. v : 3-element numpy array Unit vector pointing towards the top of the screen. w : 3-element numpy array Unit vector pointing out of the screen. E : 3-element numpy array The coordinates of the eye/camera. N)reyer+)r0rr/r,MrMtMs r_view_transformation_uvwr;Xs` B BQBrr2A2vJBrr2vJ r2A Hrc|}d}||z||z z }d||zz||z z }tj|dddgd||z ddgdd||ggdg}|S)Nrr)rrr6rr)zfrontzback focal_lengtheabr% proj_matrixs r_persp_transformationrEoswA A u %A F5L6%<(A((Q!aO!aO!aO+-.K rc d||z }||z }tjgdgdgddd||gg}|S)N)rrrr)rrrr)rrr=rrr)r>r?rBrCrDs r_ortho_transformationrG{sH 5.A 5.A((M))AqM+,K rcftj||j}|d}|d|z |d|z |d|z }}}tjj |dr.tjj ||dj }tjj |dr.tjj ||dj }tjj |dr.tjj ||dj }|||fS)Nr5rrr)mask)rr+datamaisMArrI)vecr:vecwr/txstystzss r_proj_transform_vecrRs 66!SXX D QAGAItAwqy$q'!)cC uuzz#a&eekk#CFKKk0 uuzz#a&eekk#CFKKk0 uuzz#a&eekk#CFKKk0 S=rc<tj||j}|d}|d|z |d|z |d|z }}}tj|r&tj|j t }nd|k|dkzd|kz|dkz|dkz}tjj|dr||djz}tjj|dr||djz}tjj|dr||djz}tjj||}tjj||}tjj||}||||fS)Nr5rrr)dtyper6) rr+rJisinfonesshapeboolrKrLrI masked_array) rMr:r@rNr/rOrPrQtiss r_proj_transform_vec_clipr[s` 66!SXX D QAGaKa1d1gkcC xx ggciit,SySAX&")4qASAXN uuzz#a&SV[[L  uuzz#a&SV[[L  uuzz#a&SV[[L  %%  S3$ 'C %%  S3$ 'C %%  S3$ 'C S# rc(t|||}tj||}|jdk(r|j d}t |jdD]'}|d|dk7s|dd|f|d|z |dd|f<)|d|d|dfS)zO Transform the points by the inverse of the projection matrix, *invM*. )r4)r4rrr5rNr) _vec_pad_onesrr+rWreshaperange)xsyszsinvMrMvecris r inv_transformrfs B #C 66$ D zzT||F# 4::a= !1 71:?add1gaj0DAJ1 7DGT!W $$rctjj|s>tjj|stjj|r6tjj|||tj|gStj|||tj|gSN)rrKrLr ones_like)r`rarbs rr]r]ss uuzz"~B255::b>uu{{BB R(89::xxRR\\"%5677rc4t|||}t||S)z< Transform the points by the projection matrix *M*. )r]rR)r`rarbr:rMs rproj_transformrks B #C sA &&rz3.10c>t||||tjS)N)r@)_proj_transform_cliprinf)r`rarbr:s rproj_transform_clipros BABFF CCrc6t|||}t|||S)zy Transform the points by the projection matrix and return the clipping result returns txs, tys, tzs, tis )r]r[)r`rarbr:r@rMs rrmrms! B #C #CL 99rc@tjt||Srh)r column_stack_proj_trans_points)pointsr:s r _proj_pointsrus ??-fa8 99rc~tj|}|dddf|dddf|dddf}}}t||||S)Nrrr)r asanyarrayrk)rtr:r`rarbs rrsrssF ]]6 "F1vad|VAqD\BB "b"a ((rrh)__doc__numpyr matplotlibrrr(r2r;rErGrRr[rfr]rk deprecatedrormrursrrr}s 044, "$N .  * %8'DD::)r