The Stack Overflow podcast is back! Listen to an interview with our new CEO.
8

Both methods end up doing the same calculations when you break it down. Rotating a vector $u$ with a matrix: $$\begin{bmatrix}\cos\theta & -\sin\theta \\ \sin\theta & \cos\theta\end{bmatrix} \begin{bmatrix}u_x\\u_y\end{bmatrix} = \begin{bmatrix}u_x \cos\theta - u_y\sin\theta \\ u_x \sin\theta + u_y \cos\theta \end{bmatrix}$$ Rotating a vector $u$ ...


8

This is likely more complicated than you would prefer, but: Compute the medial axis, which immediately yields the largest disks that fit inside the polygon: their centers are vertices (degree $\ge 3$) of the axis (see the figure below). Chin, Francis, Jack Snoeyink, and Cao An Wang. "Finding the medial axis of a simple polygon in linear time." Discrete &...


6

An alternative way to formulate the problem is to define a function that gives the distance between points on the two curves, as a function of the curves' parameters. Then attempt to find the global minimum of this function. If the curves intersect, the minimum will be zero; otherwise the minimum will be some positive distance. To be explicit, given a pair ...


6

You can determine x by calculating line-plane intersection. Your line starts at P and has direction D=[1, 0, 0], and plane T=[V, N]. This can be done as follows: $$x=\frac{(V-P)\cdot N}{N\cdot D}$$ x is the distance from P along D to the intersection point with T (assuming both D and N are unit vectors)


6

This is a bit different from a conventional photogrammetry problem. You're not trying to estimate a 3D world from 2D projections. You have actual 3D information - you have the imaging slices - and you want to assemble them into a 3D model. That's a much easier problem, the kind you can solve from the comfort of your couch. Do know the cutting planes that ...


6

A rigid body has 6 degrees of freedom, in 3D- space. So that means you need 6 values to represent the object. The common way to do this is to store a position vector for position and 3 rotations. But for obvious reasons any 6 variables that are independent of each other would do this. The problem with vectors is that they aren't the most efficient way to ...


5

Edit: changed the answer according to new images and clarification. for every control point p(k, n) p'(k, n) = ( p(k, n) - p(k) ) * d * l(k) + p(k, n) where k is the row index and n is the column index of control point. l is the elevation factor and is equal to {-1, -1/3, 1/3, 1}. p(k) is the center of the k'th row. Rationale: From the new images, red ...


5

What it means to "triangulate complex 3D objects" is not unambiguous. Just one possible interpretation: You have a 3D polygon in space, and you want to triangulate that. This is NP-hard: Barequet, Gill, Matthew Dickerson, and David Eppstein. "On triangulating three-dimensional polygons." Proceedings of the 12th Symposium on Computational Geometry. ACM, ...


5

[Disclaimer: I think the following should work but have not actually coded it myself] I couldn't think of a "trivial" method of producing a yes/no answer but the following would be a reasonable approach to a practical solution to the question. Let's assume our curves are A(s) and B(t) with control points {A0, A1..An} and {B0,..Bm} respectively. It seems ...


5

For a polygon to be convex the outside angle of the polygon has to be more than or equal to 180 degrees. Now at intersection of 2 lines the outermost angle has to be less than 180 degrees for the lines to intersect between the endpoints. Now the answer to this question depends on how you define what is inside of the polygon. If you consider some a even odd ...


5

FYI, the 3 other points lie on a plane Of course they do. Any set of three points defines a plane (except in the degenerate case joojaa mentions, where they lie on many planes). If the points are $p$, $q$, and $r$, then $(q - p) \wedge (r - p)$ is the normal to the plane; call it $n$. This plane defines a co-ordinate system. If you make it the XY plane, ...


4

This question should most probably be asked on GD.SE or UX.SE. These sites specialize in how to design the graphics and how to choose the graphics for your purpose. But since you are here basic options are: Routes dont overlap but are parallel like electronic layouts (image 1, A), Works well unless you have many overlapping things. Space interleaved lines, ...


4

One solution is bilinear mapping, which works for every convex quadrilateral. Let $A, B, C, D$ be the vertices of a quadrilateral $Q$ in the plane, in this order. Then $f(u,v)=(1-u)(1-v)A + u(1-v)B + uvC + (1-u)vD$ maps the square $[0,1] \times [0,1]$ to $Q$.


4

Polygon offsetting is certainly possible to do yourself. It is not nearly as involved as Bezier or B-spline offsetting is. First you want to decide how to deal with: Areas with no info, in essence how to deal with the joins. Do you just extend the line to the common intersection (miter join) or do you just connect the endpoints (bevel). You could also use ...


4

First let us solve the radius of your circle. You can see that the centers of the circles form a triangle. There are 8 possible triangles, of which 4 are mirror solutions across the line that connects the centers of your original circles. The other solutions are permutations of inside tangent and outside tangent connections. Image 1: All possible ...


4

Working Towards an Exact solution Just some quick thought before I must run! Ok, let us turn the problem on its head. What if one does not calculate the area of the triangle cut by the circle. Instead let's calculate the inverse of this. The area of three segments cut out of the circle. The beauty of this approach is that we can make a single piece of code ...


4

Idea A: Draw an invisible mesh that will occlude the points we don't want. Create a mesh from the point cloud. Render that mesh to a depth buffer but not to the color buffer. Render the point cloud using a depth test "closer or equal". This approach should give the expected result, but the problem with it is the first part, which is not trivial at all. ...


4

If you sample the two parameters $\eta$ and $\omega$ with steps $d\eta$ and $d\omega$, then you'll get a grid of points $v_{ij} = f(i\;d\eta,j\;d\omega)$. Any four adjacent points will define a quadrilateral. To get triangles, you just have to split each quad in two by a diagonal. So in the example, you'd split the quadrilateral $\{v_{00},v_{01},v_{11},v_{...


3

Well realistically your choices are either IGES or STEP. IGES is slightly simpler but you will not successfully write either format without buying the standard (which in case of step is actually so many pages that by the time you have read them a year has passed, and lots of money is wasted on paper). You could also use one of the nonstandard kernel internal ...


3

Its called a geometric constraints solver (a good primer on subject). You can find a open source solver as part of Open Cascade but its a bit convoluted to get going. A simpler solution for just solving, but also 3D solver capable, is geosolver. Making your own (algebraic solution being easiest to write) is also not that hard, just a bit of work to make it ...


3

Note that the approach you appear to be taking will only work for lines with a slope in a single octant. For the other seven octants the algorithm requires changing the approach, for example by changing the roles of x and y. Wikipedia gives a table of cases that can be used for this conversion. For this answer I will assume you are simply trying to get the ...


3

This is more of a long comment Yes you can do this. The problem lies in how you measure the surface. I tried to do this manually by progressively extruding tubes along the edges, and finding their intersection with the surface. It would work but is a bit hard to compute. Obviously you may want to take more steps than i did for a more accurate solution. ...


3

Try starting at the origin, then dividing 360 degrees by n to find some useful angles for the points of your star. I hope this drawing will help you to find a solution. Now that you have the angle theta, and the values of alpha and x are chosen by you, you have the tools to calculate all required vertices to make the star using trigonometry.


3

You already have a 2D parametrisation, don't you? One of the dimensions is the longitudal axis (in mm?) and the other is the circumferential axis (in degrees). The only problem I see is when you have rectangles wrapping around the 0/360-degree boundary. One workaround for that would be to duplicate each rectangle (or just the ones on the boundary) so that ...


3

If I understand the general idea correctly, you are going to close the gaps which are appearing after further structure growth. I cannot do it algorithmically but geometrically it is quite easy to do. I use Illustrator here and manually cover the gaps with two additional shapes. So in addition to the pentagon and flat rhombus, I will need a 5-fold star ...


3

There are different numerical approximations you could use: A simple solution is to use brute-force Monte Carlo integration. Distribute $N$ random points on the polygon and calculate the number of points inside the 3D polyhedron $N_i$ using ray tracing. The area inside the polyhedron is $A_i=A\frac{N_i}{N}$, where $A$ is the area of the polygon. To improve ...


3

Conceptually simplest would be to treat it as a ray-casting problem, representing each point as a small sphere. It should work like the shadow rays in a conventional raytracer: iterate over all of your points, and for each one, trace a ray to the camera. If the ray intersects the sphere representing another point, then remove it. If the number of points is ...


3

What you're looking for is closest point on a plane for the 3rd direction but since @DanHulme described this I would not repeat it. You can pretty easily use affine transformation matrices for this. Making a fully defined affine transform from 3 points is a pretty normal operation. The standard way is to just use a cross product to produce a third axis (...


3

According to a review by Legge & Bigelow the arc or degrees of visual angle ($\alpha$) is, $$ \alpha = 57.3 \times S/D, $$ where S is height of object and D is distance to object. [1] $S/D$ is the small angles approximation of $2 \times arctan(S/2D)$ which follows form geometry. Image 1: the equation comes straight from trigonometric definitions. ...


3

Your existing opinion is correct, though there's one extra detail. The geometric normal is the normal of the actual triangle, based on the vertices' positions (the cross-product of edge vectors, as you said). The shading normal is altered from this, and is used when shading a fragment or ray hit. In the simple case, it's the interpolation of the three ...


Only top voted, non community-wiki answers of a minimum length are eligible