MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / cameraLookAlong

Method cameraLookAlong

source/MRViewer/MRViewportCamera.cpp:793–811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791}
792
793void Viewport::cameraLookAlong( const Vector3f& newDir, const Vector3f& up )
794{
795 assert( std::abs( dot( newDir.normalized(), up.normalized() ) ) < 1e-6f );
796
797 Vector3f lookDir = cameraCenter - cameraEye;
798 auto rotLook = Matrix3f::rotation( newDir, lookDir );
799
800 auto upVec = rotLook.inverse() * cameraUp;
801 float sign = 1.0f;
802 if ( dot( cross( up, upVec ), newDir ) < 0.0f )
803 sign = -1.0f;
804
805 auto rotUp = Matrix3f::rotation( newDir, sign * angle( up, upVec ) );
806
807 params_.cameraTrackballAngle = rotLook;
808 params_.cameraTrackballAngle = params_.cameraTrackballAngle * Quaternionf( rotUp );
809
810 needRedraw_ = true;
811}
812
813void Viewport::cameraRotateAround( const Line3f& axis, float angle )
814{

Callers 6

drawDialogMethod · 0.80
drawCameraPresets_Method · 0.80
actionMethod · 0.80
actionMethod · 0.80
mcpViewerSetupCameraFunction · 0.80

Calls 6

absFunction · 0.85
dotFunction · 0.70
crossFunction · 0.50
angleFunction · 0.50
normalizedMethod · 0.45
inverseMethod · 0.45

Tested by

no test coverage detected