• Advertisement

alvaro

Member
  • Content count

    7911
  • Joined

  • Last visited

  • Days Won

    1

alvaro last won the day on April 18

alvaro had the most liked content!

Community Reputation

21349 Excellent

4 Followers

About alvaro

  • Rank
    Legend

Personal Information

  • Interests
    Programming

Recent Profile Visitors

42601 profile views
  1. Algorithm Increasing difficulty algorithm

    I think you should probably make the selection of those parameters part of the level design. Have a human decide how to set all those variables in each level. You can even have thematic sections, perhaps indicated by the background and/or the music, where perhaps all the bricks have more hit points. In other sections perhaps they move faster... Just make sure that you have easy tools to tweak the experience of playing the game.
  2. circle drawing method comparison

    Although Albert is right that these things change over time, trigonometric functions are typically very expensive. So are hard-to-predict branches, which perhaps is what's slowing down the first piece of code. It could also be that the drawing primitives are expensive, and you are making many more calls in your first piece of code than in your second piece of code. You could also start with a vector (1,0) and progressively rotate it. It would be like your second code but without most of the trigonometric function calls, or hard-to-predict branches. One more thing: Why is the function that draws 8 symmetric points in the circle called `drawBresenhamCircle'? That's very confusing.
  3. After many years of using C++, the main reason I wouldn't go back to C is std::string. Next in the list of things I would miss are destructors that make sure things are cleaned up at the right time (a.k.a., RAII, or "resource acquisition is initialization", which is a name I never quite understood). Then come containers, like std::vector. The rest of the language I could probably do without.
  4. Clockwise angle between two Vector3

    So you have two normals of adjacent convex polygons. Let's call the barycenters of the polygons A and B, and the corresponding normals vA and vB. Now compute n = cross_product(vA,vB). Now compute the [unsigned] angle between vA and vB and multiply the result by the sign of the determinant of the matrix whose columns are vA, vB and n. That's either the answer you want, or minus the answer you want. I can't be bother to figure out which, so just try it.
  5. Clockwise angle between two Vector3

    Here's the impression I got. Background first. The usual definition of angle in any dimension is the arccosine of the dot product of the normalized vectors. This is a number in [0,pi]. However, in 2D you can use something like atan2 to assign a sign to an angle, which is now a number in [-pi,pi], where positive means conterclockwise and negative means clockwise. Since adding 2*pi to an angle doesn't change anything, you can think of the angle as being in [0,2*pi) if you want. This thread is about defining angles in 3D with the features of these 2D angles I just described. Unfortunately, there is no notion of clockwise in 3D in general. It is very likely that the OP has a picture in mind that is essentially 2D (e.g., a floor), and what needs to be done is project to a plane and use the 2D definition. "Clear as mud" is a very apt description of the information we are getting from him/her. As is often the case in the Math forum, if you could express your question in correct and precise language, you probably would't need help figuring out the answer, so we should give people a little slack.
  6. WT vs SH vs AI vs binary tree

    Truly understanding linear algebra will help enormously as a base for all of these subjects. A university course is probably the best way to get there, complemented with "Essence of linear algebra": https://www.youtube.com/playlist?list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab On the wavelet transform (or wavelets more generally): https://www.amazon.com/Wavelet-Tour-Signal-Processing-Third/dp/0123743702 https://www.amazon.com/Lectures-Wavelets-CBMS-NSF-Conference-Mathematics/dp/0898712742 Also, search the web and you'll find threads on other forums where people have asked these things: https://mathoverflow.net/questions/4835/introduction-to-wavelets For AI, https://www.amazon.com/Artificial-Intelligence-Modern-Approach-3rd/dp/0136042597 On data structures (including binary trees), I liked the "Algorithms in <language>" books by Sedgewick, which I guess evolved into this: https://algs4.cs.princeton.edu/home/ . And of course you could read Knuth's "The art of computer programming", if you have nothing to do the next 10 years. For spherical harmonics I don't have a good recommendation, other than to first get very familiar with Fourier series and with orthogonal families of functions in general. Then you can just search the web and read just about any description, and it will make sense.
  7. You should never use sprintf to begin with, because it has no way of checking if you are writing past the end of the buffer. A valid alternative is snprintf. Then again, you should only use this when you need formatting. When passing the string around, when storing it or when sending it to the drawing function, you should just handle it as a plain string, without doing any formatting. EDIT: Oh, and please use std::string if you are programming in C++. You are much less likely to mess up that way.
  8. Clockwise angle between two Vector3

    Say I am looking at you face to face and I hold up a transparent sheet of plastic with the picture of two vectors on it, v1 and v2. If I measure the clockwise angle between v1 and v, I'll get a different answer than if you measure it. You need to specify from which direction you are looking at the vectors. That's where the vector n comes in. The notion of the orientation of two vectors is not well defined in 3D, so any solution you find is bound to have issues. What exactly are you trying to do?
  9. Marching Cubes and Dual Contouring Tutorial

    Actually, for any finite number of iterations, the set of points for which a divergence has not been found has a differentiable boundary. Those pictures are pretty!
  10. WT vs SH vs AI vs binary tree

    Just concentrate on learning one of the things, implement it yourself, try to use it to solve some problems. Then move on to the next one. You can try to make the big-picture connections between things once you are an expert.
  11. WT vs SH vs AI vs binary tree

    The wavelet transform is a mathematical operation, AI is a field of study and binary tree is a data structure. The interesting question is not what the difference is between them, but whether they have anything in common...
  12. Marching Cubes and Dual Contouring Tutorial

    Fractals are not differentiable, so the normal is not defined. No wonder you are having a hard time computing it.
  13. Marching Cubes and Dual Contouring Tutorial

    The link to the 3D tutorial from the 2D tutorial is broken: http://www.boristhebrave.com/2018/04/08/marching-cubes-3d-tutorial/ should be http://www.boristhebrave.com/2018/04/15/marching-cubes-tutorial/ Also, I think marching triangles and tetrahedra should be mentioned. They are an attractive alternative because the number of cases is much smaller.
  14. In case anyone is interested in a proof, here it is. If n is the number of vertices and b is the number of vertices on the boundary of the convex hull of all the points, we can add up the inner angles of all the triangles in two different ways. The angles formed around an interior point add up to 2*pi. The angles formed around a point on the boundary of the convex hull add up to pi minus a little bit. Those little bits add up to 2*pi, as you go around the convex hull once. The other way of counting it is pi * number of triangles. So we get pi*number of triangles = 2*pi*(n - b) + pi*b - 2*pi Dividing by pi, number of triangles = 2*n - b - 2 The minimum value for b is 3, so the maximum number of triangles is 2*n - 5 For the number of edges, you can use 3 * number of triangles, but most edges would have been counted twice. The edges that are not counted twice are the ones on the boundary of the convex hull, so there are b of them. You can then count the number of edges, like this: number of edges = (3 * number of triangles + b) / 2 = (6*n - 3*b - 6 + b) / 2 = 3*n - b - 3 As before, the minimum value for b is 3, so the maximum number of edges is 3*n - 6
  15. maximum number of triangles = 2 * number of vertices - 5 maximum number of edges = 3 * number of vertices - 6
  • Advertisement