Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Covariant matrix as component type #154

Closed
wdconinc opened this issue May 24, 2022 · 1 comment
Closed

Covariant matrix as component type #154

wdconinc opened this issue May 24, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@wdconinc
Copy link
Contributor

Instead of covariant matrices stored as std::array<float,6> etc, we may want to use a component such as:

  eicd::Cov3f:
    Members:
      - float xx
      - float yy
      - float zz
      - float xy
      - float xz
      - float yz
    ExtraCode:
      declaration: "
        Cov3f() : xx{0}, yy{0}, zz{0}, xy{0}, xz{0}, yz{0} {}\n
        Cov3f(double vx, double vy, double vz, double vxy = 0, double vxz = 0, double vyz = 0)\n
          : xx{static_cast<float>(vx)}, yy{static_cast<float>(vy)}, zz{static_cast<float>(vz)},\n
            xy{static_cast<float>(vxy)}, xz{static_cast<float>(vxz)}, yz{static_cast<float>(vyz)} {}\n
        float operator()(unsigned i, unsigned j) const {\n
          // diagonal\n
          if (i == j) {\n
            return *(&xx + i);\n
          }\n
          // off-diagonal\n
          // we have as options (0, 1), (0, 2) and (1, 2) (and mirrored)\n
          // note that, starting from xy, we find the correct element at (i+j-1)\n
          return *(&xy + i + j - 1);\n
        }\n
      "

(Our extra utilities are in Vector3f.h, keeping them outside of the data model)

@wdconinc wdconinc added the enhancement New feature or request label May 24, 2022
@tmadlener
Copy link
Contributor

Fixed with #287

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants