0

I have 3D vectors on the Unit Cube (from (-1,-1,-1) to (1,1,1), with all vectors v satisfying: cmax(abs(v)) == 1). I want to get the opposite vector from one to another. Example 1: A=(1,0, 0), B=(0,1, 0) ==> C=(-1,0,0) - the opposite of A along B Example 2: A=(1,1, 0), B=(1,0.5,0) ==> C=( 1,0,0) Example 3: A=(1,1,-1), B=(0,1 ,0) ==> C=(-1,1,1)

Problem: for example 3, if you naively try to rotate B by the quaternion angle from A to B, you will not get C (nor anywhere close, the difference is over 0.1). I think this is due to the Unit Cube vectors being in Manhattan space? I might be wrong.

Example problem:

    float3 RotateVectorQ(float3 object, float3 center) {
        quaternion between = Quaternion.FromToRotation(object, center);
        return math.rotate(between, center);
    }
    float3 object = (new float3(1,0,0));
    float3 center = (new float3(1,0.5f,0));
    float3 flip_object = RotateVectorQ(object, center);

```

  • You might have more luck, in general, asking these questions in a forum where the syntax you are using is familiar. It sounds like you're using a physics engine of some sort, so somewhere like gamedev.stackexchange would probably be able to give you better answers.

    That said, describing what you would like to happen for three pairs of points is not enough to figure out what function you mean by "I want to get the opposite vector from one to another". The cube is not, for instance, fixed by rotations. (The sphere is)

    – ZKe Oct 01 '23 at 18:20
  • Assuming the internal calculations are correct, for 1) through 3) you can rotate A by that "A to B" angle twice, or just "normalize" (scale) your C in such a way that the largest absolute value of coordinates becomes 1. By the way, what if C is not on the cube at all? – Amateur_Algebraist Oct 01 '23 at 18:25

0 Answers0