rianadon / Cosmos-Keyboards

Taking Keyboards to the Final Frontier
https://ryanis.cool/cosmos
GNU Affero General Public License v3.0
221 stars 24 forks source link

Column spacing isn't uniform #2

Closed acramsay closed 1 year ago

acramsay commented 1 year ago

I noticed that the columns aren't evenly spaced. You can see in the following screenshot that the gap between the "U" and "I" columns is much larger than the gap between the "I" and "o" columns. screenshot

I think this is due to how the keys are angled (transformBy) and then shifted into position. For example:

  {
    type: "mx",
    keycap: {
      profile: "mt3",
      row: 2,
      letter: "i"
    },
    aspect: 1,
    position: new Trsf()
      .placeOnMatrix({
        ...curvature,
        column: -2,
        row: -1
      })
      .transformBy(upperKeysPlane)
      .translate(0, 2.8, -6.5)
  }

Note that the translate() function doesn't alter the x-position via the first argument. So when the column is translated down (third argument), the position change is simply vertical rather than vertical relative to the upperKeysPlane. A small manual adjustment can correct this:

      .transformBy(upperKeysPlane)
      .translate(-2.5, 2.8, -5)

image

I see two possible solutions. The easy fix is to mimic my manual adjustment by changing the x position when calling the translate function. Alternatively, I think it conceptually makes more sense to set the position before the rotation. But I suspect that this is a very difficult change :)

rianadon commented 1 year ago

Hey! I saw this and I've noticed this problem as well.

Your idea of setting the position before the rotation makes a lot of sense. Putting that translate before the transformBy would be a simple fix (the code in the expert editor is almost 1:1 with the internal code), but I worry it might not solve the full issue.

The keys are also rotated through the curvature, so it might make more sense to put the translate at the very beginning, before the placeOnMatrix that applies the curvature. But since every key is rotated a different direction because of the curvature, every key would be translated in a different direction instead of all keys being moved uniformly.

Ideal would probably be to apply solely the curvature across the row (and not curvature along the column) to the translations, but that is a more difficult change :)

rianadon commented 1 year ago

I'm going to go with the first solution in my last comment. I think it makes intuitive sense to perform the staggering along the tenting plane (that way you don't need to redo the staggering after changing the tenting angle).

Making the stagger follow the curvature would be cool, but 1) it's going to be more complicated (and less intuitive adjusting in the expert mode editor) and 2) it might not even be intuitive that the x direction changes throughout the model.