Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate image #5

Open
vitrinh282 opened this issue Aug 3, 2017 · 12 comments
Open

Rotate image #5

vitrinh282 opened this issue Aug 3, 2017 · 12 comments

Comments

@vitrinh282
Copy link

rotate when i just add radianX image will rote up down,
radianY will rotate left right
but if I add two in same image will be wrong, you can try with your rotate demo change radianY 0 to 50,-50

@vitrinh282
Copy link
Author

and how to rotate the image so that it always face to the camera view point?

@szt243660543
Copy link
Owner

It's also possible to rotate X and y at the same time

@szt243660543
Copy link
Owner

if you want face to the camera view,you need calculate.

@vitrinh282
Copy link
Author

i had a position (X,Y,Z) can show you me function or formula to get rotate camera view to face.

@szt243660543
Copy link
Owner

I have to provide you with the method, that method can calculate their own rotation angle.

@vitrinh282
Copy link
Author

(GLKVector3)CalculateSphereSurfacePointWithLat:(float)lat Lon:(float)lon Depth:(float)depth
{
GLKVector3 X_Z;
// 经
X_Z.x = depth * sin(GLKMathDegreesToRadians(lon));
X_Z.y = 0;
X_Z.z = depth * - cos(GLKMathDegreesToRadians(lon));

GLKVector3 Y_Z;
// 纬
Y_Z.x = 0;
Y_Z.y = depth * sin(GLKMathDegreesToRadians(lat));
Y_Z.z = depth * - cos(GLKMathDegreesToRadians(lat));

if (lat == 0.0) {
Y_Z = GLKVector3Make(0.0, 0.0, 0.0);
}

if (lon == 0.0) {
X_Z = GLKVector3Make(0.0, 0.0, 0.0);
}

GLKVector3 dir = [MathC vector3Normalization:GLKVector3Add(X_Z, Y_Z)];
if (lat == 0.0 && lon == 0.0) {
dir = GLKVector3Make(0.0, 0.0, -1.0);
}
GLKVector3 point = GLKVector3MultiplyScalar(dir, depth);

return point;
}

// 规格化

(GLKVector3)vector3Normalization:(GLKVector3)vec3
{
float sqr = sqrt(vec3.xvec3.x + vec3.yvec3.y + vec3.z*vec3.z);
float tempx = vec3.x/sqr;
float tempy = vec3.y/sqr;
float tempz = vec3.z/sqr;

return GLKVector3Make(tempx, tempy, tempz);
}
which method ?

@vitrinh282
Copy link
Author

is those method ?

@szt243660543
Copy link
Owner

yes.

@szt243660543
Copy link
Owner

you use CalculateSphereSurfacePointWithLat method whitch i provide,then you need rotate it by using - (void)setRotate:(float)radiansX radiansY:(float)radiansY radiansZ:(float)radiansZ;

@vitrinh282
Copy link
Author

when i set long is 0 and lat is 90 ,it mean on the middle top. but image still not rotate all to face , just a part

@szt243660543
Copy link
Owner

szt243660543 commented Aug 15, 2017

if your lon is 0 ,lat is 90 and depth is 45, then you can try : setRotate:lat radiansY:-lon radiansZ:0;
you need know: lon -> y, lat->x;

@vitrinh282
Copy link
Author

maybe you wrong , we use CalculateSphereSurfacePointWithLat to calculate for rotate as you told above, why after calculate , you don't use them ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants