## Transfer coordinates from one triangle to another triangle

Let you have unknown affine transformation matrix | a c e | M =| b d f | | 0 0 1 | The first triangle vertices are (xa1, ya1), (xa2, ya2), (xa3, ya3), and the second triangle vertices have coordinates (xb1, yb1), (xb2, yb2), (xb3, yb3). Then affine transformation M that transforms the first … Read more

## Boundary enclosing a given set of points

Here is some Python code that computes the alpha-shape (concave hull) and keeps only the outer boundary. This is probably what matlab’s boundary does inside. from scipy.spatial import Delaunay import numpy as np def alpha_shape(points, alpha, only_outer=True): “”” Compute the alpha shape (concave hull) of a set of points. :param points: np.array of shape (n,2) … Read more

## How to determine whether a point (X,Y) is contained within an arc section of a circle (i.e. a Pie slice)?

Check: The angle from the centerX,centerY through X,Y should be between start&endangle. The distance from centerX,centerY to X,Y should be less then the Radius And you’ll have your answer.

## How to test if a point is inside of a convex polygon in 2D integer coordinates?

If it is convex, a trivial way to check it is that the point is laying on the same side of all the segments (if traversed in the same order). You can check that easily with the dot product (as it is proportional to the cosine of the angle formed between the segment and the … Read more

## Is there a more efficient way of texturing a circle?

Why not use: (x-x0)^2 + (y-y0)^2 <= r^2 so simply: int x0=?,y0=?,r=?; // your planet position and size int x,y,xx,rr,col; for (rr=r*r,x=-r;x<=r;x++) for (xx=x*x,y=-r;y<=r;y++) if (xx+(y*y)<=rr) { col = whateverFunctionIMake(x, y); setPixel(x0+x, y0+y, col); } all on integers, no floating or slow operations, no gaps … Do not forget to use randseed for the coloring … Read more

## algorithm to rasterize and fill a hypersphere?

well no one answers for some time so here is simple and obvious C++ solution of mine: //————————————————————————— const int N=10; // number of dimensions struct point { double a[N]; }; // N-dimensional point #define color DWORD // type of your color property //————————————————————————— // N x nested for(a=a0;a<=a1;a+=da) return false if ended // it … Read more

## How do I determine if two convex polygons intersect?

You could use this collision algorithm: To be able to decide whether two convex polygons are intersecting (touching each other) we can use the Separating Axis Theorem. Essentially: If two convex polygons are not intersecting, there exists a line that passes between them. Such a line only exists if one of the sides of one … Read more

## Efficiently find points inside a circle sector

It’s possible to check if a point is inside a sector with only integer arithmetic and the basic operations of addition, subtraction and multiplication. For a point to be inside a circular sector, it has to meet the following tests: It has to be positioned counter-clockwise from the start “arm” of the sector. It has … Read more

## Problem superimposing and aligning 3D triangles

As the other comments suggested you most likely got confused withing projections and goniometrics. There is also safer way without goniometrics using vector math (linear algebra). create transform matrix m0 representing aligned plane to first triangle t0 by aligned I mean one of the edges of triangle should lie in the one of the plane … Read more

## How to create circle with Bézier curves?

As already said: there is no exact representation of the circle using Bezier curves. To complete the other answers : for Bezier curve with n segments the optimal distance to the control points, in the sense that the middle of the curve lies on the circle itself, is (4/3)*tan(pi/(2n)). So for 4 points it is … Read more