!kGYPfZJnRmMlqqETSr:matrix.org

discord-algorithms-and-math

961 Members
Bridged room for #algorithms-and-math on the Monado discord5 Servers

Load older messages


SenderMessageTime
22 Sep 2023
@_discord_846810615082123294:t2bot.iofredinfinite23 changed their display name from fredinfinite23#0 to fredinfinite23.17:45:27
23 Sep 2023
@_discord_390178998442786816:t2bot.io418cat#0 changed their display name from 418cat to 418cat#0.18:16:37
24 Sep 2023
@_discord_150643643819098112:t2bot.io6ax3dc how do I convert from a right handed coordinate system to a left handed one? I tried to figure out the correct orientation, by applying 180 deg. on each coordinate axis with math_quat_rotate. I thought that by doing so, one (out of 9) combination would work. so iterating through 180 deg. rotations for each axis = 3axis ^ 2 = 9. but after trying all of these out, nothing seems to work. so I thought I might need to change the handedness of my coordinate system. is there any code that can assist here? or maybe someone has a better idea. 12:08:00
@_discord_150643643819098112:t2bot.io6ax3dc oh I think the answer is negating the x, y, and z components of the quaternion 🤔 12:25:27
@_discord_747039598110048297:t2bot.iozappar_simon It depends a bit how you want to map them. Typically I think of it as flipping the Z axis (typically +y is upwards on the screen, +x is to the right and the whether -z or +z is "forwards" is usually the difference). So if you've got a modelview matrix from a right handed coordinate system, then pre-multiplying by a matrix with [1 1 -1 1] on the diagonal will do it. That will make the modelview include a flip too which is a little weird - you can post multiply by the z flip too to get an equivalent model-view for left handed "object" coords to a left handed "camera" 12:51:10
@_discord_150643643819098112:t2bot.io6ax3dc I'm gonna be honest I don't understand what a modelview matrix is. is that coming from the calibration? either way I just bruteforced my way through it. turns out all I need is math_quat_from_angle_vector(DEG_TO_RAD(180), &z_axis, &rotation_quat); and then *(-1) the y and z component of the orientation quaternion. 13:42:53
@_discord_150643643819098112:t2bot.io6ax3dc * I'm gonna be honest I don't know what a modelview matrix is. is that coming from the calibration? either way I just bruteforced my way through it. turns out all I need is math_quat_from_angle_vector(DEG_TO_RAD(180), &z_axis, &rotation_quat); and then *(-1) the y and z component of the orientation quaternion. 13:43:00
@_discord_921701849717944361:t2bot.iostikmann What are the two coordinate systems? Because the answer depends on that. 14:17:23
@_discord_921701849717944361:t2bot.iostikmann Example: if one is X:Left, Y:Up, Z:Forward, and the other is X:Right, Y:Up, Z:Forward;
- You convert screen-space positions by negating the X axis
- You convert quaternions by negating Y and Z. (With quaternions, you negate and shuffle coordinates just like with position vectors, but you also have to negate XYZ if you change handedness)
14:19:09
@_discord_921701849717944361:t2bot.iostikmann * Example: if one is X:Left, Y:Up, Z:Forward, and the other is X:Right, Y:Up, Z:Forward;
- You convert screen-space positions by negating the X axis
- You convert quaternions by negating Y and Z.
With quaternions, you negate and shuffle coordinates just like with position vectors, but you also have to negate XYZ if you change handedness)
14:19:22
@_discord_921701849717944361:t2bot.iostikmann * Example: if one is X:Left, Y:Up, Z:Forward, and the other is X:Right, Y:Up, Z:Forward;
- You convert (screen-space?) positions by negating the X axis
- You convert quaternions by negating Y and Z.
With quaternions, you negate and shuffle coordinates just like with position vectors, but you also have to negate XYZ if you change handedness)
14:19:45
@_discord_921701849717944361:t2bot.iostikmann By the way, you cannot convert between different handed systems with just rotations, because you also need to mirror the system. 14:21:34
@_discord_150643643819098112:t2bot.io6ax3dc so the one from the XR50, which I use, says it uses: x to right, y to down, z to forward. and for the target I'm not sure. my guess would be: x to left, y to down, z to backward. the target should be whatever monado uses. very unsure about it.

so for the XR50 here is what works: quaternions rotated by 180 degrees around z-axis AND negated y and z. and for the position just negating y and z. I don't have an intuitive understanding if that makes sense, but testing with xrgears, it looks correct
14:38:26
@igothackedontor:matrix.orgdef(not_onion)Guys what is this channel good for15:36:20
@_discord_463264316578332693:t2bot.ioniko_20010 questions about XR (AR/VR/MR) related algorithms and math problems 15:54:04
@_discord_869640430185242715:t2bot.iobornecrantz 6ax3dc Yeah x right, y down, and z forward is the standard OpenCV coordinate system.

    /*
     * OpenCV camera space is right handed, -Y up, +Z forwards but
     * Monados camera space is right handed, +Y up, -Z forwards so we need
     * to invert y and z.
     */
    world_point.y = -world_point.y;
    world_point.z = -world_point.z;
16:19:16
@_discord_869640430185242715:t2bot.iobornecrantz * 6ax3dc Yeah x right, y down, and z forward is the standard OpenCV coordinate system.

    /*
     * OpenCV camera space is right handed, -Y up, +Z forwards but
     * Monados camera space is right handed, +Y up, -Z forwards so we need
     * to invert y and z.
     */
    world_point.y = -world_point.y;
    world_point.z = -world_point.z;
16:19:24
@_discord_559452925974413387:t2bot.io.pblack many of these ops can be done by negating components in vectors and quaternions - but the way i think about this, and apply such things, - is done more generally with a matrix - in 3d graphics when you look at a 3x3 or 4x4 matrix, you can think of its first 3 columns as vector directions for the x,y,z axes of the space it represents.

Multiplying by a matrix which is similar to an identity matrix, (i.e. column 0 is 1 0 0 (x), column 1 is 0 1 0 (y), and column 2 is 0 0 1 (z) ) but with its 'axes' changed e.g. flipping y to z and inverting the direction of z (column 0 is 1 0 0 (x) column 1 is 0 0 -1 (y is now z but inverted) column 2 is 0 1 0) (z is now y) will result in this kind of space transformation.

see https://stackoverflow.com/questions/1263072/changing-a-matrix-from-right-handed-to-left-handed-coordinate-system/71168853#71168853 for a more complete example of this..

I find the presentation of 'change of basis' in the math sense difficult to understand since it is general and applies to spaces where 'axes' are not orthonormal like we use almost exclusively in graphics - but i can easily visualise the 100/010/001 basis vectors and intuitively see how those 1s need to be exchanged and/or inverted to -1s to get my new coordinate system.. Maybe helpful when thinking about this type of thing?
18:53:58
@_discord_150643643819098112:t2bot.io6ax3dc well I tried to do it with intuition by checking on which axis the rotation is wrong in the xrgears and then tried to negate these axis'. for example when I was looking right, the view was also "turning right", and then I negated it and the view was correct. but at some point I got very confused when it wasn't for some reason acting to my intuition. then I just thought about all the possible configurations and thought "huh, not that many just try them all". it was 9 for the quaternion rotations, and then 9 for the combinations of negating these axis. so I made a nice little table and check off all combinations. worked great xd 19:00:48
@_discord_150643643819098112:t2bot.io6ax3dc althought I still don't see how it makes sense in the end. it does work, but it doesn't make sense to me. according to the XR50 docs I start with a coordinate system like: X=right, Y=down, Z=forward. and then I apply a 180 degrees rotation around the z-axis. so now I have: X=left, Y=up, Z=forward (is that correct?). then I negate the y- and z-component. so in my head I'm now flipping the positive y- and z-component to the opposite side, so I end up with: X=left, Y=down, Z=backward. but according to Jakob's comment, this isn't what monado uses, but it does work for the little testing I did. so idk, it works and I'm happy, but if anyone has some clarification, that'd be great 19:07:41
@_discord_150643643819098112:t2bot.io6ax3dc * although I still don't see how it makes sense in the end. it does work, but it doesn't make sense to me. according to the XR50 docs I start with a coordinate system like: X=right, Y=down, Z=forward. and then I apply a 180 degrees rotation around the z-axis. so now I have: X=left, Y=up, Z=forward (is that correct?). then I negate the y- and z-component. so in my head I'm now flipping the positive y- and z-component to the opposite side, so I end up with: X=left, Y=down, Z=backward. but according to Jakob's comment, this isn't what monado uses, but it does work for the little testing I did. so idk, it works and I'm happy, but if anyone has some clarification, that'd be great 19:07:47
@_discord_921701849717944361:t2bot.iostikmannRedacted or Malformed Event23:50:02
25 Sep 2023
@_discord_263862465207599105:t2bot.iomrsnippy changed their display name from MRSNIPPY to mrsnippy#0.22:48:16
@_discord_263862465207599105:t2bot.iomrsnippy changed their display name from mrsnippy#0 to mrsnippy.22:48:25
26 Sep 2023
@_discord_517072367323971620:t2bot.ioelectrolisa#0 changed their display name from electrolisa to electrolisa#0.06:38:11
@_discord_280664130476572673:t2bot.iorinlovesyou#0 changed their profile picture.12:07:35
28 Sep 2023
@_discord_195600010740498432:t2bot.ioautumnaurelium#0 changed their display name from aurelium to autumnaurelium#0.20:02:27
@_discord_195600010740498432:t2bot.ioautumnaurelium#0 changed their profile picture.20:02:39
1 Oct 2023
@_discord_169401609615441921:t2bot.iobonts#0 changed their display name from Bonts to bonts#0.05:09:59
@_discord_666489957992497182:t2bot.iodisso_peach#0 changed their display name from dissociative Peach to disso_peach#0.06:20:20

There are no newer messages yet.


Back to Room ListRoom Version: 9