jacobian.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2016 The G3N Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package equation
  5. import "github.com/g3n/engine/math32"
  6. // JacobianElement contains 6 entries, 3 spatial and 3 rotational degrees of freedom.
  7. type JacobianElement struct {
  8. spatial math32.Vector3
  9. rotational math32.Vector3
  10. }
  11. // SetSpatial sets the spatial component of the JacobianElement.
  12. func (je *JacobianElement) SetSpatial(spatial *math32.Vector3) {
  13. je.spatial = *spatial
  14. }
  15. // Spatial returns the spatial component of the JacobianElement.
  16. func (je *JacobianElement) Spatial() math32.Vector3 {
  17. return je.spatial
  18. }
  19. // Rotational sets the rotational component of the JacobianElement.
  20. func (je *JacobianElement) SetRotational(rotational *math32.Vector3) {
  21. je.rotational = *rotational
  22. }
  23. // Rotational returns the rotational component of the JacobianElement.
  24. func (je *JacobianElement) Rotational() math32.Vector3 {
  25. return je.rotational
  26. }
  27. // MultiplyElement multiplies the JacobianElement with another JacobianElement.
  28. // None of the elements are changed.
  29. func (je *JacobianElement) MultiplyElement(je2 *JacobianElement) float32 {
  30. return je.spatial.Dot(&je2.spatial) + je.rotational.Dot(&je2.rotational)
  31. }
  32. // MultiplyElement multiplies the JacobianElement with two vectors.
  33. // None of the elements are changed.
  34. func (je *JacobianElement) MultiplyVectors(spatial *math32.Vector3, rotational *math32.Vector3) float32 {
  35. return je.spatial.Dot(spatial) + je.rotational.Dot(rotational)
  36. }