0

Edit by kriegaex: This question is about yaw rotation as opposed to pitch or roll.


So, X = y = z = 0 - mins {105.0, -75.0, 0.0}, maxs {225.0, -15.0, 50.0}

So, that's what im doing (it's wrong, or it's just AABB calculating instead needed stuff).

float fMins[3]; float fMaxs[3];
float yaw = angles2[1] * (3.14 / 180.0);

float xvector[3]; float yvector[3];
xvector[0] = floatcos(yaw);
xvector[1] = floatsin(yaw);
yvector[0] = -floatsin(yaw);
yvector[1] = floatcos(yaw);
float rmin[3] = { 9999.0, 9999.0, 9999.0 };
float rmax[3] = { -9999.0, -9999.0, -9999.0 };
float base[3];
float transformed[3];

for (int i = 0; i <= 1; i++) {
  base[0] = i == 0 ? mins[0] : maxs[0];
  for (int j = 0; j <= 1; j++) {
    base[1] = j == 0 ? mins[1] : maxs[1];
    for (int k = 0; k <= 1; k++) {
      base[2] = k == 0 ? mins[2] : maxs[2];
      transformed[0] = xvector[0]*base[0] + yvector[0]*base[1];
      transformed[1] = xvector[1]*base[0] + yvector[1]*base[1];
      transformed[2] = base[2];
      /*
      if (transformed[0] < rmin[0]) rmin[0] = transformed[0];
      if (transformed[0] > rmax[0]) rmax[0] = transformed[0];
      if (transformed[1] < rmin[1]) rmin[1] = transformed[1];
      if (transformed[1] > rmax[1]) rmax[1] = transformed[1];
      if (transformed[2] < rmin[2]) rmin[2] = transformed[2];
      if (transformed[2] > rmax[2]) rmax[2] = transformed[2];
      */
      for (int l = 0; l < 3; l++) {
        if (transformed[l] < rmin[l]) rmin[l] = transformed[l];
        if (transformed[l] > rmax[l]) rmax[l] = transformed[l];
      }
    }
  }
}

fMins[0] = rmin[0]; fMaxs[0] = rmax[0];
fMins[1] = rmin[1]; fMaxs[1] = rmax[1];
fMins[2] = rmin[2]; fMaxs[2] = rmax[2];

fMins[0] += origin2[0];
fMins[1] += origin2[1];
fMins[2] += origin2[2];
fMaxs[0] += origin2[0];
fMaxs[1] += origin2[1];
fMaxs[2] += origin2[2];

So, on 0 0 0 angle's mins maxs are {105.0, -75.0, 0.0} and {225.0, -15.0, 50.0}.

How i can calculate same sizes on 0 53 0 angles?

I need same sized box, just equalent. Only mins/maxs based solutions.

  • 1
    What is "mins" and "maxs"? What are you trying to calculate? Why is this tagged C++? – HolyBlackCat May 24 '20 at 23:16
  • if u dont know what does mins maxs (rect's) means u can just skip question, idk why c++ was main tag – Arina Lubimova May 24 '20 at 23:34
  • Welcome to SO. I added syntax highlighting, fixed indentation, removed the false _aop_ tag, added a Wikipedia link. Arina, please learn what an [MCVE](https://stackoverflow.com/help/mcve) is and how to ask good questions. If you want good answers, please provide some more context next time. – kriegaex May 25 '20 at 03:29
  • You also might want to consider asking the question on https://math.stackexchange.com/ because it is both about programming and mathematics. I am no expert on analytic geometry, vectors and matrices, so without having analysed your question (which I only found because of the _aop_ tag) I cannot say for sure if you are making a mathematical or programming mistake. – kriegaex May 25 '20 at 03:56
  • if your `min,max` are AABB and you want to compute AABB after any rotation fast then your best choice is to compute&remember 3D [OBB](https://stackoverflow.com/a/42997918/2521214) and then just when needed apply rotation on the OBB and compute AABB from its 8 rotated vertexes. – Spektre May 25 '20 at 06:23
  • I don't need aabb solution, it's not what i wanna, it's already implemented, check code. It's implemented also with rotation. I need OBB (yes it's seems like AABB + rotation, but idk why it's not working, it's not equal size, that's why i need calculate exactly same size mins maxs but for angle, same sizes, but rotated), but i dont know how to implement it, so, the question main 'question' is how implement it ---- `I need same sized box, just equalent. Only mins/maxs based solutions.` --- – Arina Lubimova May 25 '20 at 08:57
  • @kriegaex aop was added coz i think that a is more perspective than c, and it's gonna be first tag, but, seems like `c++` weight is less than `aop`. – Arina Lubimova May 25 '20 at 09:00
  • Tags are not weighted or ordered, they just exist or not. AOP means aspect-oriented programming and is completely unrelated to your question. – kriegaex May 25 '20 at 10:36
  • btw u r wrong . – Arina Lubimova May 25 '20 at 11:38
  • @ArinaLubimova Your question is a mess as both text and code are inconsistent... it lacks details like what exactly is the input and what the output ... we just more or less guessed what is what... Your last comment sugets you want 3D OBB so compute it ... for that you need the vertexes of your mesh which you clearly do not have in the OP. There are more ways how to obtain OBB people usually use eigen vectors libs to obtain it. Another posibility is binary search like I did in the link from my previous comment (that is just 2D you need to port it to 3D) – Spektre May 25 '20 at 15:43
  • @ArinaLubimova Its also possible to exploit known properties of your data (like if you know the shape is a specific one you can lock onto its features instead of brute or binary searches) – Spektre May 25 '20 at 15:45
  • I specially underliying that the code inconsistent. 2 times, one in question, second one in comments. The input - given mins maxs and start position (0 0 0), and zero angles. Idk how to use any eigen stuff and then get ONLY 6 points which are same equalent (same size) but rotated for example. I need a code example. Also if it's possible check tg. – Arina Lubimova May 25 '20 at 20:06

0 Answers0