Rotate the camera around the center of the wpf object

Expression blend allows you to import 3d models. I want to animate a 3d object with code. I just can't figure out what property values ​​I need to change to make the object rotate. Let me show you what I mean:

enter image description here

therefore, if I want to rotate this object, I could use the camera’s orbit tool enter image description here , and if I use it, I can get something like:

enter image description here

I know that I can create a storyboard and create an animation by changing the object. I need to rotate the object along the x axis using the slider. If I change only one value, it will alternate along a strange path, and I really have to change several properties if I want. For example, when I rotate an object along the x axis using the camera’s orbit tool, I see that all these properties enter image description here are changing. I need to figure out which algorithm is used to rotate an object.

+6
source share
1 answer

The math to move the position of the camera around so that you rotate around the X axis is just a parametric equation of a circle:

Parametric Equation of a Circle

where t is an angle from zero to 2 pi.

Imagine that you are standing on the street looking at a house. The coordinates of the camera should follow in a circle around the house, and the latitude and longitude are constantly changing to stay at the same distance from the house. Therefore, there is no value that you can change to make it spin.

Once you know the position of the camera, the direction is simply the difference between the start and position of the camera.

All this is easy to calculate, but there is an easier way. Instead, hold the camera still and rotate the subject . This makes the animation easier. Here's an MSDN article that contains examples of this approach, including animation:

This article is for WPF and Visual Studio, but you can easily adapt the same ideas to Expression Blend.

+8
source

Source: https://habr.com/ru/post/891410/


All Articles