Lagrange
math.h
1/*
2 * Copyright 2020 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/ui/api.h>
15
16#include <Eigen/Eigen>
17#include <limits>
18
19namespace lagrange {
20namespace ui {
21
22using RowMajorMatrixXf = Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
23using RowMajorMatrixXi = Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
24
27LA_UI_API Eigen::Matrix4f normal_matrix(const Eigen::Affine3f& transform);
28
37LA_UI_API Eigen::Projective3f perspective(float fovy, float aspect, float zNear, float zFar);
38
49LA_UI_API Eigen::Projective3f
50ortho(float left, float right, float bottom, float top, float zNear, float zFar);
51
59LA_UI_API Eigen::Matrix4f
60look_at(const Eigen::Vector3f& eye, const Eigen::Vector3f& center, const Eigen::Vector3f& up);
61
70LA_UI_API Eigen::Vector3f unproject_point(
71 const Eigen::Vector3f& v,
72 const Eigen::Matrix4f& view,
73 const Eigen::Matrix4f& perspective,
74 const Eigen::Vector4f& viewport);
75
76LA_UI_API float pi();
77
79LA_UI_API float two_pi();
80
82LA_UI_API Eigen::Vector3f vector_projection(const Eigen::Vector3f& vector, const Eigen::Vector3f& onto);
83
85LA_UI_API float vector_angle(const Eigen::Vector3f& a, const Eigen::Vector3f& b);
86
87
88} // namespace ui
89} // namespace lagrange
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
LA_UI_API Eigen::Matrix4f look_at(const Eigen::Vector3f &eye, const Eigen::Vector3f &center, const Eigen::Vector3f &up)
Constructs "look at" view matrix,.
Definition: math.cpp:68
LA_UI_API Eigen::Vector3f vector_projection(const Eigen::Vector3f &vector, const Eigen::Vector3f &onto)
Projects vector onto 'onto' vector.
Definition: math.cpp:129
LA_UI_API Eigen::Projective3f perspective(float fovy, float aspect, float zNear, float zFar)
Constructs perspective projection matrix.
Definition: math.cpp:52
LA_UI_API float vector_angle(const Eigen::Vector3f &a, const Eigen::Vector3f &b)
Returns angle in radians between a and b.
Definition: math.cpp:134
LA_UI_API Eigen::Vector3f unproject_point(const Eigen::Vector3f &v, const Eigen::Matrix4f &view, const Eigen::Matrix4f &perspective, const Eigen::Vector4f &viewport)
Unprojects screen point (with x,y in screen coordinates and z in NDC) back to 3D world.
Definition: math.cpp:102
LA_UI_API float two_pi()
2 * pi
Definition: math.cpp:124
LA_UI_API Eigen::Projective3f ortho(float left, float right, float bottom, float top, float zNear, float zFar)
Constructs orthograpic projection matrix.
Definition: math.cpp:90
LA_UI_API Eigen::Matrix4f normal_matrix(const Eigen::Affine3f &transform)
Returns 4x4 transformation matrix that can be used for normals Performs transpose inverse.
Definition: math.cpp:30
Main namespace for Lagrange.
Definition: AABBIGL.h:30