Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Navigation
- Solid Edge
- Forums
- Blogs
- Knowledge Bases
- Contests
- Groups

- Siemens PLM Community
- Solid Edge
- Solid Edge Developer Forum
- Rotate camera clock/counterclockwise

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Solved!
Go to solution

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-05-2014 08:10 PM

Hi guys,

I'm using C# and I'm trying to rotate the camera clock/counterclockwise, but I couldn't figure out what's the calculation to determine the new X,Y,Z for doing that. Here's an example:

In this case it's easy, it's just rotating the Y axis:

Result:

But if the object is in a different position, I need to rotate another axis instead.

I found some similar questions in the forum but none of them are exactly what I'm looking for.

Here's my code:

public void RotateFace(int angle, bool isClockwise)

{

var axis = new double[3];

// Just rotating Y axis

axis[0] = 0;

axis[1] = isClockwise ? 1 : -1;

axis[2] = 0;

view.RotateCamera(angle, 0, 0, 0, axis[0], axis[1], axis[2]);

}

Thanks everyone.

Solved! Go to Solution.

9 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-08-2014 06:00 AM

Josh,

I just wanted to let you know that I'm deeply interested in what you're trying to do. I wish so bad that I understood the math side of CAD better. My lack of a good math education is showing...

I spoke with a dear friend of mine, John Hilton, on Skype tonight. John is absolutely amazing with this kind of stuff but getting his time is difficult. I poked and prodded him to jump in here and answer your question so we'll have to wait and see if he has time. Fingers crossed.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-08-2014 04:54 PM

Thanks for the effort, man. Hopefully he'll show up here. Last time I've asked something related to that in this forum, a guy called Martin helped me a lot. Seems he's no longer here though.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-09-2014 07:43 AM

Josh,

hope I understand your requirements.

In the video below I transformed the rootpoint and the normalvector of the refplane at the tip of the arrows to the topassembly and used

view.RotateCamera(angle, X(rootpoint), Y(rootpoint), Z(rootpoint), _

n*X(normalvector), n*Y(normalvector), n*Z(normalvector))

regards

Gerald

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-10-2014 03:32 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-10-2014 05:50 AM

Josh,

the video is public now.

I wrote a module to get and transform Rootpoint, Normalvector and Matrix, it works for me but unfortunately I don't really know why.

Occurrence.GetMatrix TM(1 to 16)

RefPlane.GetRootPoint RP(1 to 3)

RefPlane.GetNormal NV(1 to3)

For i = 1 to 3

RP_Transformed= TM(i) * RP(1) + TM(i + 4) * RP(2) + TM(i + 8) * RP(3) + TM(i + 12)

NV_Transformed= TM(i) * NV(1) + TM(i + 4) * NV(2) + TM(i + 8) * NV(3)

next

RP_Transformed and NV_Transformed are my values to rotate the camera.

HTH

Gerald

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-10-2014 06:46 AM

Hi Gerald,

Thanks for your reply. In your video you are pretty much rotating axis X, Y and Z individually. I'm looking for some sort of calculation to rotate all of them at once, no matter what's the current position of the object. I think it would be something like this:

var eye = new double[3];

var target = new double[3];

var up = new double[3];

var isPerspective = false;

double scale = 0;

view.GetCamera(out eye[0], out eye[1], out eye[2], out target[0], out target[1], out target[2], out up[0], out up[1], out up[2], out isPerspective, out scale);

const int angle = 20;

// Compute the normalized view direction

var viewDir = new double[3];

viewDir[0] = target[0] - eye[0];

viewDir[1] = target[1] - eye[1];

viewDir[2] = target[2] - eye[2];

double len = Math.Sqrt(viewDir[0] * viewDir[0] + viewDir[1] * viewDir[1] + viewDir[2] * viewDir[2]);

if (len > 1.0E-5)

{

viewDir[0] /= len;

viewDir[1] /= len;

viewDir[2] /= len;

}

// var axis = DO SOME CALCULATION HERE TO DETERMINE X, Y, Z

view.RotateCamera(angle, 0, 0, 0, axis[0], axis[1], axis[2]);

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-10-2014 07:25 AM

Solution

Solution

Accepted by topic author JoshBaumann

08-26-2015
04:32 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-10-2014 07:48 AM

Josh,

if you want to rotate around the axis of the camera like in the video below you can use

view.RotateCamera(angle, out target[0], out target[1], out target[2], out eye[0] - out target[0], out eye[1] - out target[1], out eye[2] - out target[2]);

Gerald

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

09-11-2014 03:33 AM

Gerald, you the guy! With your code I could achieve what I was looking for! Thanks man

Follow Siemens PLM Software

© 2017 Siemens Product Lifecycle Management Software Inc