
C++
Frank(Zhiyang-Dou)
A Ph.D. candidate at HKU. Mainly focus on CG.
展开
-
Cmake OPENCV_NOT_FOUND
问题描述Cmake OPENCV_NOT_FOUND解决根据你的build路径在cmake gui中设置变量:继续编译即可。原创 2021-05-25 19:20:32 · 1077 阅读 · 1 评论 -
vs17 原有的C++库找不到
问题在vs17上,原有的C++库找不到。解决Project -> Properties -> General -> Windows SDK Version -> select 10.0.17134.0原创 2020-03-11 23:26:00 · 514 阅读 · 0 评论 -
RuntimeError: Ninja is required to load C++ extensions
综述RuntimeError: Ninja is required to load C++ extensions之前使用python实现的项目,优化框架不够高效,准备转到C++解决安装ninja第一步:安装chocolatey : https://chocolatey.org/install在powershell中运行管理员权限,输入你copy的安装代码。第二步: choco ...原创 2020-03-01 10:16:15 · 18433 阅读 · 7 评论 -
decltype操作
综述decltype是获得编译时类型推导一种操作。说到该操作,还有一个很类似的:auto关键字。他们的区别在于:”decltype的类型推导并不是像auto一样是从变量声明的初始化表达式获得变量的类型,而是总是以一个普通表达式作为参数,返回该表达式的类型,而且decltype并不会对表达式进行求值。"refhttps://www.cnblogs.com/QG-whz/p/4952980...原创 2020-02-13 22:13:31 · 290 阅读 · 0 评论 -
vector从头插入元素
综述vector从头插入元素代码 vector<int> icon; for (int i = 0; i < 10; i++) { icon.insert(icon.begin(), i); } for (auto ele : icon) { cout << ele << endl; }原创 2020-02-08 21:57:21 · 9969 阅读 · 1 评论 -
C++ vector释放内存
综述C++ vector释放内存。近期面临处理数据规模较大的情况,然后一开始使用clear释放内存,结果出错了。后来才知道原来clear方法并没有真正释放内存。记录一下,避免再次踩坑。正确的释放方法应该是: vcon.size(); vcon.shrink_to_fit();而不是只是 vcon.size();代码对比vector<int> vcon; for...原创 2020-02-08 17:24:20 · 1501 阅读 · 0 评论 -
计算树中节点的公共祖先
综述项目需要计算树中节点的公共祖先。注意这里的树不一定是二叉树(这里假设每个节点)。基本性质:每一个节点到公共根节点的路径是唯一的。从任何一个节点向其父亲追踪最后一定落在root处。思路对节点i,ji, ji,j而言。我们首先从iii开始不断遍历iii的父亲节点; 将这些节点压入一个stack a\text{stack}\ astack a。然后从jjj开...原创 2020-02-08 17:12:48 · 437 阅读 · 0 评论 -
C++程序运行时间
综述使用chrono进行计时。(计时相对精准)代码#include <chrono>using namespace std; int a = 1, b = 1; int c; chrono::steady_clock::time_point now = chrono::steady_clock::now(); c = a + b; auto t22 = ch...原创 2020-02-04 20:40:56 · 444 阅读 · 0 评论 -
Ubuntu16.04 install openCV c++/c
综述Ubuntu16.04 install openCVc++/c地址一行命令的事:https://github.com/jayrambhia/Install-OpenCV/blob/master/Ubuntu/opencv_latest.sh原创 2019-07-26 11:03:34 · 823 阅读 · 0 评论 -
在三角形面上均匀采样
综述在面片上均匀采样结果代码#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>#include <CGAL/Regular_triangulation_3.h>#include <CGAL/Weighted_point_3.h>#include <iostream&...原创 2019-07-11 23:25:49 · 2110 阅读 · 0 评论 -
C++判断点和平面的位置关系
点与平面的位置关系如果令法向量N为(A,B,C),点P0为。则平面的方程为:Ax+By+Cz+D=0对于点P0,代入后满足NP0 + D = 0所以D = -NP0;判断某点和某平面的位置关系可以依照上面三个判断式,如下:判断式位置关系Ax+By+Cz+D=0点(x,y,z)在平面上Ax+By+Cz+D>0点(x,y,z)在正半空间Ax+B...原创 2019-07-10 21:40:07 · 4978 阅读 · 0 评论 -
C++自定义数据结构以及输出重载
C++输出<<重载方法ostream& operator<< (ostream& out, Edge& s){ out << "("<< s.u <<"," << s.v <<")" ; return out;}ostream& operator<<...原创 2019-07-10 19:14:38 · 821 阅读 · 0 评论 -
C++文件读取模版
综述一个cpp的文件读取模版。库#include <fstream>#include <string>代码string selected_poles_path = "/Users/frankdura/Desktop/a.txt";//set the file path ifstream in(selected_poles_path); //...原创 2019-07-05 13:58:13 · 431 阅读 · 0 评论 -
C++计算对数函数
综述c++计算对数函数,简单记录一下。代码#include<iostream>#include<cmath>using namespace std;int main(){ double a=2; //以2为底 cout << log(4)/log(a)<<endl; return 0;}...原创 2019-04-02 20:08:50 · 13189 阅读 · 0 评论 -
C++ max()函数 error: no matching function for call to 'max'
综述C++的max/min函数一般都很常用。一般来说如果是windows的话,头文件<windows.h>是有定义min,max的。#include <windows.h>但是mac上一般(基于C11)可以使用#include <algorithm>...原创 2019-05-11 20:09:34 · 10414 阅读 · 0 评论 -
C++ “no matching function for call to 'atoi/atof'” error
综述报错 “no matching function for call to ‘atoi/atof’” error代码首先确保你设置了using namespace std;其次,注意大概率是你使用了string而不是char数组所以:改为string inputstr = "111";i = atoi(inputstr.c_str());即可...原创 2019-05-11 20:21:57 · 6648 阅读 · 4 评论 -
如何将网易云ncm格式转换为mp3格式
综述网易云下载音乐发现时ncm格式,结果导致我们在其他媒介上很难享受音乐。搜集了一下将ncm格式转换的方式。强烈推荐CentOS 下转换网易云音乐ncm格式为mp3步骤打开终端terminal依次输入yum install openssl openssl-devel gcc-c++ git taglib taglib-devel -ygit clone https://gith...原创 2019-05-25 19:51:07 · 27417 阅读 · 4 评论 -
C++遍历文件目录
C++遍历文件目录综述代码综述C++程序遍历目录是十分频繁的需求。比如有时候需要设计一个批处理程序,帮助我们完成机械重复的工作。代码#include <iostream>#include<fstream>#include <sys/dir.h>#include <sys/stat.h>using namespace std;boo...原创 2019-05-18 17:41:42 · 1563 阅读 · 0 评论 -
C++-计算三角形面片的法线代码
综述C+±计算三角形面片的法线代码;随手记下来,免得找不到库依然是CGAL 11代码Point calTriNormal( Point ver1, Point ver2, Point ver3 ){double temp1[3], temp2[3],normal[3];double length = 0.0;temp1[0] = ver1[0] - ver2[0];...原创 2019-07-09 15:50:06 · 3341 阅读 · 0 评论 -
C++-计算点到三角形距离代码
综述C+±计算点到三角形距离代码库CGAL 11代码double Point2tridistace(Point onepoint, Point triangle1,Point triangle2,Point triangle3 ){ // the point and the vertex of the triangle // output the distance ...原创 2019-07-09 16:00:33 · 2495 阅读 · 0 评论 -
C++-向量的点乘、叉乘等操作
综述向量的点乘、叉乘等操作。代码double ThreeDot(Point p,Point a,Point b){ return(a[0]-p[0])*(b[0]-p[0])+(a[1]-p[1])*(b[1]-p[1])+(a[2]-p[2])*(b[2]-p[2]);}//pa与pb的点积 (3点) Point ThreeCross(Point p,Point a,...原创 2019-07-09 18:48:25 · 16817 阅读 · 0 评论 -
set自定义比较-pair两元素比较
两元素次序无关#include <iostream>#include <set>using namespace std;class Edge{public: int u; int v; Edge(int u, int v): u(u), v(v){} bool operator< (const Edge& e) c...翻译 2019-07-04 14:57:09 · 999 阅读 · 0 评论 -
自定义Edge/Face数据结构 set定义元素比较次序
综述自定义Edge/Face数据结构 set定义元素比较次序代码Face.cpp#include <set>#include <iostream>using namespace std;class Face{public: //the three points int u; int v; int k; Face(i...原创 2019-07-10 13:36:41 · 674 阅读 · 0 评论 -
C++规范格式读取
综述只是做个备份,最近需要做一些规范化数据读取的操作。代码#include <fstream>#include <iostream>#include <vector>using namespace std;#ifndef N#define N 1000#endifstruct Powerpoint{ int id; int...原创 2018-10-21 20:02:01 · 762 阅读 · 0 评论