> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/api/flatredball/camera/rotationmatrix.md).

# RotationMatrix

### Introduction

The Camera object inherits from the PositionedObject class. Therefore, it can be rotated just like any other PositionedObject. For information on using rotation values on a PositionedObject in general, see the following pages:

* [FlatRedBall.PositionedObject.RotationX](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php)
* [FlatRedBall.PositionedObject.RotationY](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php)
* [FlatRedBall.PositionedObject.RotationZ](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php)
* [FlatRedBall.PositionedObject.RotationMatrix](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php)

By default the Camera will attempt to orient itself so that "up" is the Y vector (0,1,0). For more information see the [UpVector page](/flatredball/api/flatredball/camera/upvector.md).

### Code Example

The Camera can be rotated to be facing any direction. Keep in mind that many systems in FlatRedBall are designed to work in 2D, so making a game with a rotated Camera is more difficult. The following shows how to rotate the camera to simulate looking at an angle at a "floor" made up of the redball graphic. Add the following code to either Game1.cs's Initialize function, or your Screen's CustomInitialize function:

```
 for (int x = 0; x < 10; x++)
 {
     for (int y = 0; y < 10; y++)
     {
         Sprite sprite = SpriteManager.AddSprite("redball.bmp");
         // Default Sprites are 2x2 so we need to multiply by 2 to make
         // them sit end-to-end
         sprite.X = x * 2;
         sprite.Y = y * 2;
     }
 }

 // Now let's rotate the Camera on the Y axis so it looks at an angle:
 // Making this number larger will make the camera more at the horizon.
 // Making the number smaller will make the camera look more at the ground.
 // A value of 0 is perfectly top-down.  A value of Math.PI/2 (about 1.51)
 // will make the camera look at the horizon.
 SpriteManager.Camera.RotationX = .6f;

 SpriteManager.Camera.X = 10;

 // We need to move the camera down a bit so it can look up at the Sprites:
 SpriteManager.Camera.Y = -5;

 // Let's bring the camera "closer to the ground"
 SpriteManager.Camera.Z = 20;

 // If the camera is rotated, we need to turn off cull mode:
 SpriteManager.Camera.CameraCullMode = CameraCullMode.None;
```

![RotatedCamera.PNG](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-de333a59ef2399e296a83c40ee13a40381e92ccf%2Fmigrated_media-RotatedCamera.PNG?alt=media)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flatredball.com/flatredball/api/flatredball/camera/rotationmatrix.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
