Skip to main content
Share Your Experience: Take the 2024 Developer Survey
6 votes

Rounding corners of polygon given vertices of its corners

Ok, Xenapior and Reynolds together have the right idea. But the explanation is a bit lacking so here is a image to explain it all and some further musings. First let us start by drawing an image (yes ...
joojaa's user avatar
  • 8,437
6 votes
Accepted

Converting cartesian pixels to polar pixels

I have implemented the cartesian-to-polar-conversion and have used different interpolation methods: 1) nearest neighbor 2) a subsampling approach, which averages 81 subpixel locations 3) bilinear ...
NodeCode's user avatar
  • 341
5 votes
Accepted

Explanation of the Marching Squares saddle points resolution

Imagine that a black dot represents a value of -1 whereas a white dot represents a value of +1. You are looking for the iso-line(s) where each point upon the line is 0. For this example you could ...
JustABit's user avatar
  • 176
5 votes
Accepted

What if we don't mention Modelview and projection matrix?

Your screen isn't 3D, so how do you display 3D objects on it? You need to map 3D coordinates into 2D space. This also explains why your OpenGL code is not behaving how you're expecting it to. Sorry if ...
aces's user avatar
  • 1,353
4 votes

How can I transform an ellipse into a circle?

You can use a shear, or equivalently a rotation by 45, scale along one of the axes, rotate back (which is equivalent to the shear which you are looking for). EDIT: On second thought, you don't need ...
lightxbulb's user avatar
  • 2,226
3 votes
Accepted

When fitting 3d cuboids into a box, how to find the order of drawing (in a 2D projection) so that the cuboids don't appear to overlap?

Let's get our orientation straight first. When I speak of a direction, I mean the direction relative to our viewpoint. So the "front" face of a cuboid is the face nearest the camera; "...
Nicol Bolas's user avatar
  • 9,832
3 votes
Accepted

What is the difference between world coordinate, viewing coordinate and device coordinate in computer graphics?

The 2D pipeline involves ... [coordinate transformation terms] Can someone give me the detail differentiation among these? This is something I very recently learned while trying to understand how ...
RoboticForest's user avatar
3 votes

Algorithm for thinning a thick line

the canny algorithm is a great start. it takes a sobel input like so. Computes its gradient. Then depending on the gradient orientation it compares all neighbouring pixels aligned with it. If its a ...
Paul Goux's user avatar
3 votes

2D metaballs with marching squares and linear interpolation

as promised, here my answer to your question. As I can't follow your code completely (I spend most of my time implementing my code :D ) I can only explain to you what the last step is. So why do we ...
realvictorprm's user avatar
2 votes

Successive lineTo(x, y) in JavaScript

Straight from the specification of lineTo: If the object's path has no subpaths, then ensure there is a subpath for (x, y). And "ensure that there is a subpath" ...
Martin Ender's user avatar
  • 2,730
2 votes
Accepted

Douglas-Peuker and equal distances

I would consider the curvature in that case too. If the curvature is small - then it is a flat region - so you can safely remove it - your 4th point for example. If the curvature is large (your 5th ...
lightxbulb's user avatar
  • 2,226
2 votes
Accepted

My 2D translation matrix causes the box to be off screen when it shouldnt be

The mistake was in the multiplication order during the composition of the matrices. Since the OP was working with column vectors the correct order for transformations should have been $TRSA∗v$. The ...
gallickgunner's user avatar
2 votes

How to apply wire texture for realistic rendering of embroidery?

Picking up from step 2, where you generated line segments to represent individual stitches, I would first suggest that you apply rounded ends to each segment, rather than square ends. I would then ...
Jack's user avatar
  • 341
2 votes
Accepted

Purpose and workflow of wireframe models

Why are wireframes used? Games don't really use wireframes much, but they might be useful for HUD items etc. Asset creators, designers and engineers use wireframes to see whats inside objects. TO ...
joojaa's user avatar
  • 8,437
2 votes

Purpose and workflow of wireframe models

Regarding wireframes as an edge list. Wireframe models are used in engineering and CAD they provide several benefits. The Wikipedia page you linked has some benefits, this AutoCAD page has some more. ...
pmw1234's user avatar
  • 3,219
2 votes

How do I plot tristimulus curves?

You can certainly convert the wavelengths of the visible spectrum into the XYZ colour space with some extra considerations. Converting wavelengths of the visible spectrum into RGB will present some ...
Timothy Maguire's user avatar
1 vote

2d gpu powered rendering engine

Writing a 2D render system is a perfectly reasonable thing to do using any of the Graphics API's that you listed. Triangles are the basic medium of all the popular graphics API's so learning to work ...
pmw1234's user avatar
  • 3,219
1 vote
Accepted

Is drawing Bezier curve with scanline algorithm possible with Vulkan?

The typical solution is to compute a bounding structure using triangles that would be transformed by the vertex shader. The bounding structure is computed to be large enough to fit the entire curve ...
pmw1234's user avatar
  • 3,219
1 vote

Rigorous example of early graphics system

First of all, the type of system they describe is more commonly known today as a vector display. (Until just now, I had never heard it called “calligraphic”.) Looking up information using that name ...
Kevin Reid's user avatar
  • 1,136
1 vote

Recursive sampling in Marching Squares

If the contour exists in a loop entirely inside one of your coarse cells — or has some thin protrusion that passes between the corner points, at least — then it will be missed entirely; it will look ...
Kevin Reid's user avatar
  • 1,136
1 vote

Whats the best way to render (2D) parametric curves with uniform stroke width?

Your question implies that everything has to be rendered with a vertex representing each small piece of a curve. This simply isn't accurate. It also implies that device rendering space is in some way ...
pmw1234's user avatar
  • 3,219
1 vote

undefined reference to `SDL_setRenderDrawColor'

Looks like a typo since the compiler isn't complaining about the other SDL function calls. You probably need to change SDL_setRenderDrawColor to ...
Joshua Kennedy's user avatar
1 vote
Accepted

Algorithms for rendering overlapping (floating) windows in 2D

I have some knowledge of what you call “stacking” (I don't know if there's a standard term), from having programmed with classic Mac OS graphics (QuickDraw). To keep the explanation straightforward, I'...
Kevin Reid's user avatar
  • 1,136
1 vote

wall clock using bresenhams circle drawing algo

The usual method is to just draw over the circle with your lines. The clock is behind the minute hand and the minute hand is behind the hour hand so the drawing order would be. Draw the clock face, ...
pmw1234's user avatar
  • 3,219
1 vote
Accepted

Algorithm for proper drawing of cosine function

There is in fact a way to avoid this effect and it is outlined by the NYQUIST sampling theorem - which states that the sampling rate should be at least twice as high as the maximum frequency of the ...
Elijah Nicol's user avatar
1 vote

How can I draw a filled circle on a grid with the less rectangle as possible?

To get a proper circle, you can use a transformation matrix to transform your cell coordinates into equally spaced cartesian coordinates. In the case of your 50 x 100 pixel cells, your transformation ...
user1118321's user avatar
  • 3,421
1 vote

Rounding corners of polygon given vertices of its corners

The cut length from the vertex is x*ctan(t/2), where t is the angle at this vertex.
Xenapior's user avatar
1 vote
Accepted

Rounding corners of polygon given vertices of its corners

Since you're working on CAD software, you probably want some precise results. Here an algorithm that could work: For each side: Compute the segment's equation. Compute each round corner's circle ...
bernie's user avatar
  • 830
1 vote
Accepted

Determining Vanishing Points of edges of Triangle using given Point

Vanishing points are "points at infinity" in projective geometry, which are represented by $w = 0$ in homogeneous coordinates. You can construct the vanishing point of a ray or line by taking its $xyz$...
Nathan Reed's user avatar
1 vote

Fill an irregular region with 2D shapes

There is no general algorithm for packing problems. Only some of the special cases have known, and optimal, solutions. If you are packing one shape then finding a reasonable solution is possible. Like ...
joojaa's user avatar
  • 8,437

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