Skip to content

Instantly share code, notes, and snippets.

View v3c70r's full-sized avatar
🐱
Cats typing ...

QGu v3c70r

🐱
Cats typing ...
View GitHub Profile
@v3c70r
v3c70r / CMakeLists.txt
Created January 10, 2017 21:48
CodeCoverage using cmake
# An example of how to use gcov/lcov with cmake.
cmake_minimum_required (VERSION 2.8.11)
project(testing)
set (CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
set (CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
add_executable(exe test.cpp)
@v3c70r
v3c70r / plot.glsl
Created December 2, 2016 21:30
Plot f(x) or f(y) on screen.
float plotX(vec2 st, float pct){
return smoothstep( pct-0.01, pct, st.y) -
smoothstep( pct, pct+0.01, st.y);
}
float plotY(vec2 st, float pct){
return smoothstep( pct - 0.01, pct, st.x) -
smoothstep(pct, pct + 0.01, st.x);
}
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <iostream>
#include <vector>
#include <stdexcept>
#include <functional>
#include <cstring>
#include <set>
//全是伪代码
preMousePos;
updateCamera()
{
if (leftBtnPressed)
{
curMousePos = glfwGetMousePos();
mouseDiff = curMousPose - preMousePos;
applyRotationToCamera(mouseDiff);
preMousePos = curMousePos;
static vec findNearestPoint(vector<vec> line1, vector<vec>line2)
{
//vec p_0 = {line1[0](0), line1[0](1), line1[0](2)};
//vec q_0 = {line2[0](0), line2[0](1), line2[0](2)};
vec p_0 = line1[0];
vec q_0 = line2[0];
vec u = line1[1];
vec v = line2[1];
/* Copyright (C)
* 2016 - Tsing Gu
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@v3c70r
v3c70r / CMakeLists.txt
Last active February 16, 2016 17:10
CMake tricks
# List all elements in a var
FOREACH(item ${OPENGL_LIBRARIES})
MESSAGE(STATUS ${item})
ENDFOREACH(item)
@v3c70r
v3c70r / rotationAxis.md
Last active October 6, 2015 17:17
rotationAxis.md

First, you need to find a plan that parallel to projection plan in object space. gluUnproject() function gonna do the trick for you.

GLint gluUnProject(
	GLdouble winX,  
	GLdouble winY, 
	GLdouble winZ,  
	const GLdouble * model,  
	const GLdouble * proj, 
@v3c70r
v3c70r / nltk.py
Created September 25, 2015 04:27
'''
This is a NLTK testing script.
AITS: http://www.ai.sri.com/natural-language/projects/arpa-sls/atis.html
'''
import nltk;
#print "Loading Sentence... "
std::ifstream inFile(objFile);
if (!inFile.is_open())
{
std::cout<<fileName<<" does not exist\n";
exit(-1);
}
std::string str;
std::cout<<"Loading "<<objFile<<"..."<<std::endl;
while (std::getline(inFile, str)) //read position
{