Public Group

# Why RotationMatrix keeps its value? xna

This topic is 4001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

when I call SetTriggerMatrix() function, the object scales and rotates (it keeps rotating it does not hold the angle) It should only scale, T_Angle does not change. rotationMatrix value stays the same with each loop, I dont see why the object is turning. When I change T_Angle to 360 it does not rotate if T_Angle is 90 it iterates by 90

if (newState.IsKeyDown(Keys.Right))
{
// setscale can be commented out, the object still rotates
MyTriggers[MyTriggers.Count - 1].SetScale += 2.0f;
MyTriggers[MyTriggers.Count - 1].SetTriggerMatrix();
}

public void SetTriggerMatrix()
{
List<Vector3> TmpList = new List<Vector3>();

TmpList = TList; // TList always stays the same

// make an angle in degrees
//***************************************************************************
//************************Problem Area**************************************

// make a rotation matrix
Matrix rotationMatrix = Matrix.CreateRotationZ(angle);

for (int i = 0; i < TmpList.Count; i++)
TmpList = Vector3.Transform(TmpList, rotationMatrix);
//***************************************************************************
//***************************************************************************


//this code below is not important, it just finishes off the above function // I was getting xml erros is the reason for posting this outside of the code. // scale first then add location TListVec2.Clear(); for (int i = 0; i < TmpList.Count; i++) { TListVec2.Add(new Vector2(TmpList.X * Scale + TriggerLocation.X, TmpList.Y * Scale + TriggerLocation.Y)); } } [Edited by - pascalosti on November 4, 2007 9:57:43 PM]

##### Share on other sites
Every time through the loop, you re-apply the matrix transformation. The matrix transformation rotates the vectors. What's surprising? Also, why would you want that to happen? If the user holds the key, he will expect to keep turning.

##### Share on other sites
How can I apply transformation only once? My thought was that every vector has to be rotated or transformed. then scaled then set to its location.

// these are the vectors im going through, they always stay the same

// and what my screen looks like (45angle)

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632950
• Total Posts
3009382
• ### Who's Online (See full list)

There are no registered users currently online

×