itsbenedict:

Hey, serious math friends who know how to do a math good? I gotta do a thing with some vectors for a game, but the only solution that’s jumping to mind for the thing seems complicated and expensive and I want to make sure I’m not missing some really simple math thing that makes it as simple as it seems like it ought to be.

So, this is in 3D, but presumably the same principles should apply in 2D- let’s say you have a known vector u, and a variable vector v, and you want to get… the point that corresponds to where you’d end up if you followed v and then, treating the direction of v as the positive y axis, followed u. Like:

image

(the application here is that I want an object to move to a defined position and orientation relative to the camera.)

So, like, my immediate brute-force solution here is to compute the angle A of v relative to the y-axis, then compute a vector u’ that’s been rotated by A, and then add u’ to v to get my point. Except, that involves a bunch of trig calculations, which I would intuitively assume to be pretty expensive on the processor compared to adds or mults, and I’m going to be computing this position every frame.

So is there like, a name for this operation? And a faster way to calculate it than doing a bunch of trig?

(via obstinaterixatrix)

boost

  1. earnest-peer reblogged this from itsbenedict and added:
    Has someone brought you the good news about quaternions yet? I don’t know actually what those good news are, but...
  2. itsbenedict reblogged this from nostalgebraist and added:
    That paper is pretty sweet, and totally satisfies my curiosity wrt/whether there’s a non-trig way to do this! (The...
  3. nostalgebraist reblogged this from itsbenedict and added:
    Applying a rotation to a vector can be represented as multiplying the vector by a certain kind of matrix, so we need to...
  4. ravenousrain88 reblogged this from mx-mythical and added:
    you could break vectors u and v into their x and y subcomponents, so you would have 4 vectors u_x, u_y, v_x, v_y. Adding...
  5. mx-mythical reblogged this from obstinaterixatrix
  6. obstinaterixatrix reblogged this from itsbenedict