Jump to content
  • Advertisement

alvaro

Member
  • Content count

    7919
  • Joined

  • Last visited

  • Days Won

    1

alvaro last won the day on April 18

alvaro had the most liked content!

Community Reputation

21353 Excellent

4 Followers

About alvaro

  • Rank
    Legend

Personal Information

  • Industry Role
    Programmer
  • Interests
    Programming

Recent Profile Visitors

42774 profile views
  1. alvaro

    Separating components of a free form rotation

    I don't understand your "straightforward" plan . Try to explain very carefully what you are trying to do. The first word I don't understand in your description is "affect". I am not being pedantic: I honestly don't understand what you are trying to do, even if I substitute "effect" there. "Tweening" (I had to look it up) presumably refers to interpolation, but between what and what? If you expand the cross product, you'll see that your rotation vector is something very simple, like (delta.Y, delta.X, 0.0) or something like that. The way your code is written obscures what's going on.
  2. alvaro

    Architecture of code in a game

    Those techniques are probably not worth it for a small game, but a small game could be a good test bed to get familiar with the techniques, so you can then use them in larger games. I would recommend re-implementing Snake in several different ways, to see what works and what doesn't. You will then be better prepared to make design decisions in more sophisticated projects.
  3. Those formulas are only valid if you are using a spherical model for Earth. Ellipsoid models do have some number called "N", but I haven't bothered to figure out the details. See this, for example: https://en.wikipedia.org/wiki/Reference_ellipsoid The OP hasn't posted enough detail for me to be inclined to help.
  4. Here's something that is much faster, although I don't know how applicable it is to your situation. Let's say you are looking for a pattern of K bits inside a long sequence of N bits. The naive algorithm to do this runs in time O(K*N), but you can do it in O(N*log(N)) using FFT, if you can reduce the problem to computing a convolution. If you are really interested in this possibility, let me know and I'll try to flesh out the idea, perhaps even with some sample code.
  5. First, it's a good idea to measure how much of the time is going to what operation. For instance, you seem to think that the pow is expensive, but how much faster is your algorithm if you remove it? Once you have a good idea of what the slow parts are, it's easier to think of optimizations. Here's another idea: Since the quality of each attempted match can be computed independently from all the others, you could program a GPU to run this algorithm. That could be a very big speed up.
  6. I just want to mention that pow(x, 8) will probably be computed as three multiplications, so it shouldn't be expensive.
  7. Maybe because you ignored the correlations between the variables? Also, if you could post the full example it would be helpful.
  8. alvaro

    Get Angle of 3D Line and Rotate Polygon With Result

    I am having a hard time understanding what you are trying to do. I think part of the problem is that there are several notions that seem to be somewhat confused here: Angle: This is a single number that tells you how far apart the directions of two vectors are. Rotation: This is what is described with yaw, pitch and roll (or in many other ways). Direction: A class of vectors that are proportional to each other. If you are trying to align a polygon to another polygon, you need to find the normal directions to both polygons and then find a rotation that aligns one to the other. There are many such rotations, but there is a notion of "shortest rotation". But again, I am not sure what you are trying to do.
  9. alvaro

    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.
  10. alvaro

    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.
  11. 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.
  12. alvaro

    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.
  13. alvaro

    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.
  14. alvaro

    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.
  15. 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.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!