   transform problems
  http://www.dejawolf.com/transformcopy.rarhello, i've been trying to get this thing to work for the past month or so. its a small program where i'm trying to get a triangle to attach/detach itself to another object on command, and retain its original position and rotation in worldspace. i've managed to get an object to attach itself to another, and be offset from that object in 3d space, thats not really a problem, but getting it to retain its orientation when it gets attached i'm having a hard time figuring out. and it doesn't really help that i'm uncertain whether its XNA doing things in a weird way, or me. one of the ideas of how to make it work that i had, was to find the rotation angle betweenthe red and blue triangle, and somehow get a multiplier from that angle to multiply the red triangles local axis movement. i was thinking pythagoras to get the magnitude of the rotation vector, and then sin(angle)*magnitude cos(angle)*magnitudebut its just leading to abysmal failure, and my brain is fried, and refuse to cooperate anymore.this is the current code: A.Rotation = Rotation;  A.Position = Position;  A.Offset = Offset;  Matrix Offsetmatrix = Matrix.CreateTranslation(A.Offset);   Matrix translatematrix = Matrix.CreateTranslation(A.Position);  Matrix RotateMatrix =  Matrix.CreateRotationZ(A.Rotation);  A.transform = Offsetmatrix *RotateMatrix * translatematrix;  Matrix OffsetmatrixB = Matrix.CreateTranslation(B.Offset); ;  Matrix translatematrixB = Matrix.CreateTranslation(B.Position);  Matrix RotateMatrixB = Matrix.CreateRotationZ(B.Rotation);  B.transform = OffsetmatrixB * RotateMatrixB * translatematrixB;  if (zoom == true)  { //this little thing actually moves the model to the origin, and rotates it to 0.0f, and then puts it back where it was. float storedRot = Rotation; Vector3 storedPos = Position; Rotation -= storedRot; Position -= storedPos;  B.Rotation -= storedRot; testlinelength -= vmath.BRENN(storedPos, B.Rotation);B.Offset -= storedPos; //B.Position -= storedPos; //testlinelength = vmath.findposition(B.Offset, (-90*((float)Math.PI/180)) ); //testlinelength = vmath.findposition( B.Offset, B.Rotation); //if you remove these 2, you will see that the model is actually moved to the origin. //Rotation = storedRot; //Position = storedPos; //stores the variables for output into strings. checkrotation = storedRot; checkposition = storedPos; //Rotation += 0.1f; B.Storepos = B.Offset; boolean = "true";  }  if (zoom == false)  { boolean = "false";// Rotation = 0.5f;  }   public static Vector3 BRENN(Vector3 offset, float rotation)   {  Vector3 worldpos = new Vector3(0, 0, 0);  float linelength;  linelength = (float)Math.Sqrt((offset.X * offset.X) + (offset.Y * offset.Y));  float radius = linelength;  worldpos.X = (float)Math.Cos(rotation) * linelength;  worldpos.Y = (float)Math.Sin(rotation) * linelength;  return worldpos;   }[Edited by - dejawolf on May 19, 2010 3:17:34 AM]
  don't know if this will clear things up:http://www.dejawolf.com/whatiwant.jpg   ;  some additional info to clear up some potential confusion:this is what i want:1.B is located at 50,0,0A is located at 0,0,02.you move A to 20,0,0 and rotate 35 degrees. then you hit N to attach B to A. B stays at 50,0,0 in worldspace, but now has the the equivalent location in A's local space. this could be -27, 2, 0 for example. it depends on where A was when B got attached.3.B rotates and moves with A, until N is pressed again. now B is dislocated from A, but it retains the position and orientation it had last, when it was detached from A.   