## Find The Center Of Discrete Points & Get Projected Vector On Direction

I want to find the central point, not mass center, between a few points like the following image. The points are on the same plane. Find the longest axis and the orthogonal axis for the points set firstly. Compute the positive farthest point and negative farthest point for every axis. Read more…

## VTK – Make Interpolation Spline Curve Smoother

Here are a few points like the following picture. The source code: #include <iostream> #include <vector> #include <iostream> #include <vtkPolyData.h> #include <vtkProperty.h> #include <vtkPolyDataMapper.h> #include <vtkActor.h> #include <vtkPlane.h> #include <vtkRenderer.h> #include <vtkRenderWindow.h> #include <vtkRenderWindowInteractor.h> #include <vtkPoints.h> #include <vtkInteractorStyleTrackballCamera.h> #include “./point.hpp” #include <vtkPlane.h> #include <vtkPlaneSource.h> #include <vtkTransform.h> #define vtkSPtr vtkSmartPointer #define Read more…

## Find Closest Plane Between Points In 3D By Covariance Matrix

The post is similar to Find Closest Plane Between Points In 3D By Levmar Algorithm. The vtkPlane in vtk9.0.2 or the newer version provides a way to calculate the fitting plane for a few points. static bool ComputeBestFittingPlane(vtkPoints* pts, double* origin, double* normal);. The origin will be the centroid of Read more…

## The Matrix Of Rotate Around The Axis In 3d

As with 2D transforms, any 3D transformation matrix can be decomposed using SVD into a rotation, scale, and another rotation. Any symmetric 3D matrix has an eigenvalue decomposition into rotation, scale, and inverse-rotation. Finally, a 3D rotation can be decomposed into a product of 3D shear matrices. Rotate about z-axis: Read more…

## 3D – Rotate Axis System To The Special Orientation

The post is based on https://www.weiy.city/2021/11/vtk-rotate-vector-to-special-direction/. We will rotate the three axes of the world coordinate system to particular directions. #include <iostream> #include <vtkSmartPointer.h> #include <vtkTransform.h> #include <vtkActor.h> #include <vtkConeSource.h> #include <vtkRenderer.h> #include <vtkRenderWindow.h> #include <vtkPolyDataMapper.h> #include <vtkRenderWindowInteractor.h> #include <vtkAxesActor.h> #include “../point.hpp” using namespace std; double AngleBeteewnTwoVector( Point vec0, Point Read more…

## Overview Of GJK Algorithm

Here is a convex object and an origin point outside it. is an arbitrary point in the boundary. Find the farthest point on the boundary along the vector . Name the farthest point . We get a new vector to find the farthest point on the boundary along the direction Read more…

## VTK – Separating Meshe By Connectivity

I export scene from ParaView to get a mesh like the following image. Let’s take edge lists from different parts and form two independent meshes. #include <iostream> #include <vtkSmartPointer.h> #include <vtkSphereSource.h> #include <vtkActor.h> #include <vtkConeSource.h> #include <vtkRenderer.h> #include <vtkRenderWindow.h> #include <vtkPolyDataMapper.h> #include <vtkRenderWindowInteractor.h> #include <vtkCellData.h> #include <vtkNamedColors.h> #include <vtkColorTransferFunction.h> #include Read more…

## The Stability Of Sorting Algorithm

If two numbers are equal and the relative positions are not changed after sorting, we think the sorting algorithm is stable. Stable sort algorithm: bubble sort, insert sort and merge sort. Unstable sort algorithm: quick sort, heap sort. Introduce an unstable sort algorithm quick sort. Its core thought is divide Read more…

## CPP : typeid.name and initializer_list

typeid.name The function typeid.name can give us the information about variable. Header file: typeinfo #include <typeinfo> int main() { vector<bool> vec{ false, true }; auto ans = vec[0]; cout << typeid(ans).name() << endl; bool tmp = false; cout << typeid(tmp).name() << endl; int value = 12; cout << typeid(value).name() << Read more…

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X