class_docstr: A Dyadic object.
  
  See:
  https://en.wikipedia.org/wiki/Dyadic_tensor
  Kane, T., Levinson, D. Dynamics Theory and Applications. 1985 McGraw-Hill
  
  A more powerful way to represent a rigid body's inertia. While it is more
  complex, by choosing Dyadic components to be in body fixed basis vectors,
  the resulting matrix is equivalent to the inertia tensor.
class_docstr_tok: ["A","Dyadic","object",".","See",":","https",":","\/\/en.wikipedia.org\/wiki\/Dyadic_tensor","Kane",",","T.",",","Levinson",",","D.","Dynamics","Theory","and","Applications",".","1985","McGraw-Hill","A","more","powerful","way","to","represent","a","rigid","body","'s","inertia",".","While","it","is","more","complex",",","by","choosing","Dyadic","components","to","be","in","body","fixed","basis","vectors",",","the","resulting","matrix","is","equivalent","to","the","inertia","tensor","."]
docstr: Returns the matrix form of the dyadic with respect to one or two
  reference frames.
  
  Parameters
  ----------
  reference_frame : ReferenceFrame
      The reference frame that the rows and columns of the matrix
      correspond to. If a second reference frame is provided, this
      only corresponds to the rows of the matrix.
  second_reference_frame : ReferenceFrame, optional, default=None
      The reference frame that the columns of the matrix correspond
      to.
  
  Returns
  -------
  matrix : ImmutableMatrix, shape(3,3)
      The matrix that gives the 2D tensor form.
  
  Examples
  ========
  
  >>> from sympy import symbols, trigsimp
  >>> from sympy.physics.vector import ReferenceFrame
  >>> from sympy.physics.mechanics import inertia
  >>> Ixx, Iyy, Izz, Ixy, Iyz, Ixz = symbols('Ixx, Iyy, Izz, Ixy, Iyz, Ixz')
  >>> N = ReferenceFrame('N')
  >>> inertia_dyadic = inertia(N, Ixx, Iyy, Izz, Ixy, Iyz, Ixz)
  >>> inertia_dyadic.to_matrix(N)
  Matrix([
  [Ixx, Ixy, Ixz],
  [Ixy, Iyy, Iyz],
  [Ixz, Iyz, Izz]])
  >>> beta = symbols('beta')
  >>> A = N.orientnew('A', 'Axis', (beta, N.x))
  >>> trigsimp(inertia_dyadic.to_matrix(A))
  Matrix([
  [                           Ixx,                                           Ixy*cos(beta) + Ixz*sin(beta),                                           -Ixy*sin(beta) + Ixz*cos(beta)],
  [ Ixy*cos(beta) + Ixz*sin(beta), Iyy*cos(2*beta)/2 + Iyy/2 + Iyz*sin(2*beta) - Izz*cos(2*beta)/2 + Izz/2,                 -Iyy*sin(2*beta)/2 + Iyz*cos(2*beta) + Izz*sin(2*beta)/2],
  [-Ixy*sin(beta) + Ixz*cos(beta),                -Iyy*sin(2*beta)/2 + Iyz*cos(2*beta) + Izz*sin(2*beta)/2, -Iyy*cos(2*beta)/2 + Iyy/2 - Iyz*sin(2*beta) + Izz*cos(2*beta)/2 + Izz/2]])
docstr_tok: ["Returns","the","matrix","form","of","the","dyadic","with","respect","to","one","or","two","reference","frames",".","Parameters","--","--","--","--","--","reference_frame",":","ReferenceFrame","The","reference","frame","that","the","rows","and","columns","of","the","matrix","correspond","to",".","If","a","second","reference","frame","is","provided",",","this","only","corresponds","to","the","rows","of","the","matrix",".","second_reference_frame",":","ReferenceFrame",",","optional",",","default=None","The","reference","frame","that","the","columns","of","the","matrix","correspond","to",".","Returns","--","--","--","-","matrix",":","ImmutableMatrix",",","shape","(","3,3",")","The","matrix","that","gives","the","2D","tensor","form",".","Examples","========",">",">",">","from","sympy","import","symbols",",","trigsimp",">",">",">","from","sympy.physics.vector","import","ReferenceFrame",">",">",">","from","sympy.physics.mechanics","import","inertia",">",">",">","Ixx",",","Iyy",",","Izz",",","Ixy",",","Iyz",",","Ixz","=","symbols","(","'Ixx",",","Iyy",",","Izz",",","Ixy",",","Iyz",",","Ixz","'",")",">",">",">","N","=","ReferenceFrame","(","'N","'",")",">",">",">","inertia_dyadic","=","inertia","(","N",",","Ixx",",","Iyy",",","Izz",",","Ixy",",","Iyz",",","Ixz",")",">",">",">","inertia_dyadic.to_matrix","(","N",")","Matrix","(","[","[","Ixx",",","Ixy",",","Ixz","]",",","[","Ixy",",","Iyy",",","Iyz","]",",","[","Ixz",",","Iyz",",","Izz","]","]",")",">",">",">","beta","=","symbols","(","'beta","'",")",">",">",">","A","=","N.orientnew","(","'","A","'",",","'Axis","'",",","(","beta",",","N.x",")",")",">",">",">","trigsimp","(","inertia_dyadic.to_matrix","(","A",")",")","Matrix","(","[","[","Ixx",",","Ixy","*","cos","(","beta",")","+","Ixz","*","sin","(","beta",")",",","-Ixy","*","sin","(","beta",")","+","Ixz","*","cos","(","beta",")","]",",","[","Ixy","*","cos","(","beta",")","+","Ixz","*","sin","(","beta",")",",","Iyy","*","cos","(","2","*","beta",")","\/2","+","Iyy\/2","+","Iyz","*","sin","(","2","*","beta",")","-","Izz","*","cos","(","2","*","beta",")","\/2","+","Izz\/2",",","-Iyy","*","sin","(","2","*","beta",")","\/2","+","Iyz","*","cos","(","2","*","beta",")","+","Izz","*","sin","(","2","*","beta",")","\/2","]",",","[","-Ixy","*","sin","(","beta",")","+","Ixz","*","cos","(","beta",")",",","-Iyy","*","sin","(","2","*","beta",")","\/2","+","Iyz","*","cos","(","2","*","beta",")","+","Izz","*","sin","(","2","*","beta",")","\/2",",","-Iyy","*","cos","(","2","*","beta",")","\/2","+","Iyy\/2","-","Iyz","*","sin","(","2","*","beta",")","+","Izz","*","cos","(","2","*","beta",")","\/2","+","Izz\/2","]","]",")"]
code: def to_matrix(self, reference_frame, second_reference_frame=None):
      """Returns the matrix form of the dyadic with respect to one or two
      reference frames.
  
      Parameters
      ----------
      reference_frame : ReferenceFrame
          The reference frame that the rows and columns of the matrix
          correspond to. If a second reference frame is provided, this
          only corresponds to the rows of the matrix.
      second_reference_frame : ReferenceFrame, optional, default=None
          The reference frame that the columns of the matrix correspond
          to.
  
      Returns
      -------
      matrix : ImmutableMatrix, shape(3,3)
          The matrix that gives the 2D tensor form.
  
      Examples
      ========
  
      >>> from sympy import symbols, trigsimp
      >>> from sympy.physics.vector import ReferenceFrame
      >>> from sympy.physics.mechanics import inertia
      >>> Ixx, Iyy, Izz, Ixy, Iyz, Ixz = symbols('Ixx, Iyy, Izz, Ixy, Iyz, Ixz')
      >>> N = ReferenceFrame('N')
      >>> inertia_dyadic = inertia(N, Ixx, Iyy, Izz, Ixy, Iyz, Ixz)
      >>> inertia_dyadic.to_matrix(N)
      Matrix([
      [Ixx, Ixy, Ixz],
      [Ixy, Iyy, Iyz],
      [Ixz, Iyz, Izz]])
      >>> beta = symbols('beta')
      >>> A = N.orientnew('A', 'Axis', (beta, N.x))
      >>> trigsimp(inertia_dyadic.to_matrix(A))
      Matrix([
      [                           Ixx,                                           Ixy*cos(beta) + Ixz*sin(beta),                                           -Ixy*sin(beta) + Ixz*cos(beta)],
      [ Ixy*cos(beta) + Ixz*sin(beta), Iyy*cos(2*beta)/2 + Iyy/2 + Iyz*sin(2*beta) - Izz*cos(2*beta)/2 + Izz/2,                 -Iyy*sin(2*beta)/2 + Iyz*cos(2*beta) + Izz*sin(2*beta)/2],
      [-Ixy*sin(beta) + Ixz*cos(beta),                -Iyy*sin(2*beta)/2 + Iyz*cos(2*beta) + Izz*sin(2*beta)/2, -Iyy*cos(2*beta)/2 + Iyy/2 - Iyz*sin(2*beta) + Izz*cos(2*beta)/2 + Izz/2]])
  
      """
  
      if second_reference_frame is None:
          second_reference_frame = reference_frame
  
      return Matrix(
          [
              i.dot(self).dot(j)
              for i in reference_frame
              for j in second_reference_frame
          ]
      ).reshape(3, 3)
  
imports: from sympy import sympify, Add, ImmutableMatrix
  from sympy.core.evalf import EvalfMixin
  from sympy.printing.defaults import Printable
  from mpmath.libmp.libmpf import prec_to_dps
label_desc: Use image node_id 19 for calling the Dyadic obj's underlying member method code with example usage: obj.to_matrix(reference_frame, second_reference_frame) and returns: Matrix