This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <GLFW/glfw3.h> | |
#include "imgui/imgui.h" | |
#include "imgui/imgui_impl_glfw.h" | |
#include "imgui/imgui_impl_opengl3.h" | |
#include "camera_trackball.h" | |
const float FOVY = 60.0f; | |
const float NEARCLIP = 0.1f; | |
const float FARCLIP = 150.0f; | |
const int FPS = 30; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <GLFW/glfw3.h> | |
#include <glm/gtc/type_ptr.hpp> | |
void TrackballCamera::lookAt() { | |
CameraAxes axes = compute_axes(); | |
const glm::vec3 eye = center_ - r_ * axes.front; | |
glm::mat4 view = glm::lookAt(eye, center_, GRAVITY_UP); | |
glMatrixMode(GL_MODELVIEW); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void TrackballCamera::rotate(float dx, float dy) { | |
phi_ += 0.5 * M_PI * dy; | |
theta_ += 0.5 * M_PI * dx; | |
// Clamp phi to ]-pi/2, pi/2[ | |
static const float PHI_MIN = -0.5 * M_PI + 0.001f; | |
static const float PHI_MAX = 0.5 * M_PI - 0.001f; | |
phi_ = std::min(std::max(phi_, PHI_MIN), PHI_MAX); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <glm/glm.hpp> | |
const glm::vec3 TrackballCamera::GRAVITY_UP(0.f, -1.f, 0.f); | |
CameraAxes TrackballCamera::compute_axes() const { | |
const glm::vec3 front = glm::normalize(glm::vec3(-cos(phi_)*sin(theta_), | |
sin(phi_), | |
-cos(phi_)*cos(theta_))); | |
const glm::vec3 right = glm::normalize(glm::cross(front, GRAVITY_UP)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <glm/glm.hpp> | |
struct CameraAxes { | |
glm::vec3 right; | |
glm::vec3 down; | |
glm::vec3 front; | |
}; | |
class TrackballCamera { | |
public: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float cohesion_factor_; | |
float alignment_factor_; | |
float separation_factor_; | |
// ... Provide elapsed time dt | |
// Update Position/Speed | |
for (size_t i = 0; i < n_boids; i++){ | |
glm::vec3& boid_i = boid_positions[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float cohesion_factor_; | |
float alignment_factor_; | |
float separation_factor_; | |
// ... Provide elapsed time dt | |
// Combine Forces | |
for (size_t i = 0; i < n_boids; i++){ | |
glm::vec3& boid_i = boid_positions[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <algorithm> | |
#include <glm/glm.hpp> | |
std::vector<glm::vec3> boid_positions; | |
std::vector<glm::vec3> boid_speeds; | |
float separation_min_dist_; // In case boids distance is close to zero | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import open3d as o3d | |
import time | |
# Load colored XYZ vertices of the Pointcloud | |
my_pcd_path = "my/pcd/path" | |
o3d_pcd = o3d.io.read_point_cloud(my_pcd_path) | |
xyz = np.asarray(o3d_pcd.points) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from typing import Tuple | |
def render_pcd(xyz: np.ndarray, rgb: np.ndarray, | |
img_360_h: int) -> Tuple[np.ndarray, np.ndarray]: | |
"""Render a spherical image from a colored pointcloud""" | |
img_360_w = 2*img_360_h | |
list_phi, list_theta, list_r = cartesian_to_spherical(xyz) | |
list_u, list_v = spherical_angles_to_pixels(list_phi, list_theta, |