Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 Mar 2002
Offline Last Active Today, 05:48 PM

#5246024 Basic Programming Knowledge Need Some Advice

Posted by Álvaro on 12 August 2015 - 11:42 AM

I actually think xoxos is a bad programmer. When you first learn programming you think of the code as a way to communicate to the computer what to do. After many years of programming I (like many others) realized that humans will end up having to read your code (other humans, or you in a few months, which you can think of as another human), and clarity is the most important metric for your code (even beyond correctness, I think; although that is debatable).

#5245321 Error Upper Bounds for Initial-Value Problems

Posted by Álvaro on 09 August 2015 - 05:13 PM

You can take the derivative of anything with a bit of template magic. You can read about the basic ideas here: https://en.wikipedia.org/wiki/Automatic_differentiation . I found some libraries in the past that implemented both forward and reverse modes using C++ templates, and I have written my own implementations as well.

#5244526 How would I solve this polynomial equation system?

Posted by Álvaro on 04 August 2015 - 12:01 PM

The system of equations in the first post is asking for three points x, y and z in a line such that the distance from x to y is sqrt(2), the distance from y to z is sqrt(2) and the distance from z to x is sqrt(2). Obviously that doesn't have any solutions.

I didn't quite follow your last post.

#5240798 How do you write this down?

Posted by Álvaro on 16 July 2015 - 08:47 AM

  if( v > 0 )
    if( doA() )
    if( doB() )
That part is just weird. I cannot imagine what `doA' and `doB' could be that would make code like that make sense.

EDIT: Also, are you sure that `else' matches the right `if'?

#5240770 Need to make app for ipad without apple products...

Posted by Álvaro on 16 July 2015 - 06:45 AM

Whether HTML5 can do the job or not, it seems kind of crazy to develop for a target platform without having the hardware to test it on. The cost of an iPad is small compared to the value of your time developing the app (whether you are getting paid for it or doing it for free).

#5239848 How to calculate a quaternion rotation between 2 vectors with a specific fina...

Posted by Álvaro on 11 July 2015 - 09:16 PM

Oh, performance certainly matters for games, I am not challenging that. But most likely you are going to be doing this operation one time per frame or so, and it's not going to be a bottleneck.

It's generally better to write code that is as clear as possible, without introducing horrible algorithmic inefficiencies. Then if your code is not fast enough, use a profiler to try to locate the parts of the code that can most benefit from optimization.

#5239079 airplane engine sound

Posted by Álvaro on 08 July 2015 - 04:45 PM

From the little I've heard about making noises for movies and videogames, it's almost impossible to generate good sounds completely from scratch. What's wrong with using some real samples to work with and then mess with them in different ways to make them sound the way you want?

#5239009 Simulating the sun

Posted by Álvaro on 08 July 2015 - 09:59 AM

In coordinates where East is (1,0,0), North is (0,1,0) and up is (0,0,1), the direction of the sun at sunrises ("91° east of due south") is (sin(91°), -cos(91°), 0). At sunset it's (-sin(91°), -cos(91°), 0). In between it will presumably be (sin(91°) * cos(alpha), -cos(91°), sin(91°) * sin(alpha)), where alpha is a number that changes from -90° at sunrise to +90° at sunset.

EDIT: No, that formula is wrong. I have to think about it a bit more. You need to take the latitude into account.

#5238664 MipMap count : counter or math is better ?

Posted by Álvaro on 06 July 2015 - 02:55 PM

Those floating-point operations are very expensive. You are generally better off doing manipulations with integers, although there are faster methods than your loop.

32 - __builtin_clz(max(height, width)); // gcc only; but I am sure other compilers have similar constructs

#5238098 Portal view

Posted by Álvaro on 02 July 2015 - 06:57 PM

I assume you are talking about holes in the wall, like in the Portal video game. Each portal has an associated reference frame. There is an affine transformation that maps one reference frame to the other one. You need to transform the camera through that transformation (or its inverse, depending on how you label things).

#5238097 Help with MiniMax Algorithm for Tic Tac Toe

Posted by Álvaro on 02 July 2015 - 06:52 PM

Well, a perfect opportunity for you to figure out how to debug recursive calls. smile.png

#5237765 How do I make this game I'm thinking about?

Posted by Álvaro on 30 June 2015 - 05:38 PM

Do you mean "Je ne regrette rien" ??

That's the song. I was quoting the first line of the lyrics.

#5237721 How do I make this game I'm thinking about?

Posted by Álvaro on 30 June 2015 - 01:22 PM

That wasn't what I meant, I meant how do I play a game within the same game, like recursion.

A game within a game? Be careful of going too deep. If time flies by when having fun with just 1 game, it flies by twice as fast in a game within a game. You’ll need a kick to get you out.

Non... rien de rien... smile.png

#5237600 Search Algorithm for fast key lookup?

Posted by Álvaro on 29 June 2015 - 07:40 PM

Look up spatial partitioning methods. That's probably what you need.

#5237519 orthonormal rotation and a quaternion bijection?

Posted by Álvaro on 29 June 2015 - 10:56 AM

So quaternions with a different sign will map to a different orthonormal matrix right?

No, quaternions that differ only in the sign will map to the same orthonormal matrix.

I didn't understand the rest.