Code Monkey home page Code Monkey logo

Comments (4)

zfergus avatar zfergus commented on May 22, 2024 1

One other thing: in all the code the DOF that derivatives are taken with respect to are the vertices flattened row-wise. That is, for vertices

v0x v0y v0z
v1x v1y v1z
     ⋮

you will get the derivatives in the order

v0x
v0y
v0z
v1x
v1y
v1z
 ⋮

from ipc-toolkit.

Andlon avatar Andlon commented on May 22, 2024

I couldn't label this as documentation and ended up with bug. Perhaps it should have been enhancement, as it's not really a bug!

from ipc-toolkit.

zfergus avatar zfergus commented on May 22, 2024

Thanks again for pointing this out.

CollisionMesh::build_from_full_mesh takes the full (volumetric) mesh vertices and surface edges/faces which index into the full mesh vertices. It then builds a selection matrix to go from full to surface vertices and maps the edge/faces entries accordingly.

CollisionConstraints::compute_potential_hessian returns a matrix of size vertices.size()xvertices.size() (vertices.size() = vertices.rows() * vertices.cols()). Where vertices are the CollisionMesh's vertices (i.e., just the surface vertices if you are working with a volumetric mesh).

If you then want the Hessian in terms of the full (volumetric) mesh that was used to build the collision mesh there is the function:

/// @brief Map a matrix quantity on the collision mesh to the full mesh.
/// This is useful for mapping Hessians from the collision mesh to the full
/// mesh (i.e., applies the chain-rule).
/// @param X Matrix quantity on the collision mesh with size equal to ndof() × ndof().
/// @return Matrix quantity on the full mesh with size equal to full_ndof() × full_ndof().
Eigen::SparseMatrix<double> CollisionMesh::to_full_dof(const Eigen::SparseMatrix<double>& X) const;

This handles applying the chain rule of going from full to surface vertices (i.e., multiplying by the transpose of the selection matrix).

Hopefully, this answers your questions.

P.s. I was thinking I will finally add a basic example in the docs of all this (like #5 asked for). Hopefully, that will help new users get started. In the meantime don't hesitate to reach out with any other questions.

from ipc-toolkit.

Andlon avatar Andlon commented on May 22, 2024

Thanks @zfergus, that really helps clear things up! I think that might just have saved me from some headaches later :-)

from ipc-toolkit.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.