// Copyright 2021 DeepMind Technologies Limited // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef MUJOCO_SRC_USER_USER_UTIL_H_ #define MUJOCO_SRC_USER_USER_UTIL_H_ #include #include #include extern const double mjNAN; // used to mark undefined fields const double mjEPS = 1E-14; // minimum value in various calculations const double mjMINMASS = 1E-6; // minimum mass allowed // check if numeric variable is defined: !_isnan(num) bool mjuu_defined(const double num); // compute linear address of M[g1][g2] where M is triangular n-by-n // return -1 if inputs are invalid int mjuu_matadr(int g1, int g2, const int n); // set 4D vector void mjuu_setvec(double* dest, const double x, const double y, const double z, const double w); void mjuu_setvec(float* dest, const double x, const double y, const double z, const double w); // set 3D vector void mjuu_setvec(double* dest, const double x, const double y, const double z); void mjuu_setvec(float* dest, const double x, const double y, const double z); // set 2D vector void mjuu_setvec(double* dest, const double x, const double y); // copy double array void mjuu_copyvec(double* dest, const double* src, const int n); // copy float array void mjuu_copyvec(float* dest, const float* src, const int n); // zero array void mjuu_zerovec(double* dest, const int n); // dot-product in 3D double mjuu_dot3(const double* a, const double* b); // distance beween 3D points double mjuu_dist3(const double* a, const double* b); // L1 norm between vectors double mjuu_L1(const double* a, const double* b, int n); // normalize vector to unit length, return previous length // if norm(vec) mjuu_parseContentTypeAttrType(std::string_view text); // return subtype from content_type format {type}/{subtype}[;{parameter}={value}] std::optional mjuu_parseContentTypeAttrSubtype(std::string_view text); // convert filename extension to content type; return empty string if not found std::string mjuu_extToContentType(std::string_view filename); #endif // MUJOCO_SRC_USER_USER_UTIL_H_