Skip to content

Instantly share code, notes, and snippets.

@newpolaris
newpolaris / source.cpp
Last active May 6, 2023 16:31
bullet debug draw
#include <iostream>
#include <bullet/btBulletDynamicsCommon.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <vector>
#include <string>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
#include <memory>
using std::unique_ptr;
using std::shared_ptr;
using std::weak_ptr;
template <typename T>
class UniquePointer {
public:
@newpolaris
newpolaris / GetProjectFromCameraMtx2
Created February 9, 2022 13:16
GetProjectFromCameraMtx2
// http://jamesgregson.blogspot.com/2011/11/matching-calibrated-cameras-with-opengl.html
// 결과는 거의 같은데, (3,3), (3,4), (4,3)이 여긴 죄다 양수임
// https://ksimek.github.io/2013/06/03/calibrated_cameras_in_opengl/ 여기서는 음수임
glm::mat4 GetProjectFromCameraMtx2(const glm::mat3& cameraMatrix, float near, float far)
{
float fx = cameraMatrix[0][0];
float fy = cameraMatrix[1][1];
float cx = cameraMatrix[2][0];
float cy = cameraMatrix[2][1];
Eigen::Matrix4d proj;
grammar Material;
@lexer::members {
boolean ignoreNewLine = true;
}
material_list :
material
| material_list material
;
// 오차가 계속 누적되는 듯
glm::vec3 angle = glm::eulerAngles(B.rotation);
angle = glm::degrees(angle);
ImGui::SliderFloat3("Rotation", (float*)&angle, -180.f, 180.f);
angle.y = glm::clamp(angle.y, -91.f, 91.f);
B.rotation = glm::radians(angle);
y에 90을 넣어도, 다시 들어올때는 89.98 정도가 나옴
eulerAngles 함수는 -90 ~ 90 이 제한임 // https://gamedev.stackexchange.com/questions/183771/euler-angle-and-quaternion-conversion-become-weird-when-yaw-is-bigger-than-90-de
// acos and cross product version
glm::mat4 RotationBetweenVectors() {
glm::vec4 c = glm::vec4(center, 0.f, 1.0);
glm::vec4 o = transform * glm::vec4(objectPoint, 0.0, 1.0);
glm::vec4 t = glm::vec4(lineTo, 0.0, 1.0);
auto t_ = glm::vec3(t - c);
auto o_ = glm::vec3(o - c);
auto a = glm::normalize(o_);
auto b = glm::normalize(t_);
@newpolaris
newpolaris / ShowVertexNumber.cs
Last active April 24, 2025 09:46
display vertex id in unity
// Editor script that displays the number and UV coordinates of each individual vertex making up a triangle within a mesh
// To install, place in the Assets folder of a Unity project
// Open via Window > Show Vertex Info
// Author: Luke Gane
// Last updated: 2015-02-07
using UnityEditor;
using UnityEngine;
public class ShowVertexNumber : EditorWindow {
// Dear ImGui: standalone example application for GLFW + OpenGL 3, using programmable pipeline
// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.)
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
// Read online: https://github.com/ocornut/imgui/tree/master/docs
#define _CRT_SECURE_NO_WARNINGS
#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
@newpolaris
newpolaris / vimrc
Last active June 1, 2021 06:18
vimrc.vimrc
" ============================================================================
" newpolaris's vim
"
"---------------------------------------------- ----------------------
set nocompatible " be iMproved, required
filetype off " required
" e! ++enc=euc-kr
set nocompatible " be iMproved, required
@newpolaris
newpolaris / datagen_plot.py
Last active May 3, 2021 03:08
polynomialRegiression
// https://himbopsa.tistory.com/13
import numpy as np
import matplotlib.pyplot as plt
x = 5 * np.random.rand(1,150)
y = -2 * pow(x,3) + 9 *pow(x,2) + -3 * x + 7 + 4 * np.random.rand(1,150)
xx = open("data_150.txt","w")
xx.write("150")