Navigating though the surface of a hypersphere in OpenGL -


maybe fits in math.stackexchange.com, since programing in opengl, shall ask here.

i had idea of spaceship game world confined in surface of 4-d hypersphere (also called 3-sphere). thus, in seeing inside, 3-d world, navigating in every direction, never leave limited volume of 3-sphere.

to represent 3-shpere "flat" 3-d space, use stereographic projection, simple implement glsl shader, need divide input vector 1 minus w coordinate.

to represent vertices of objects using normalized 4d vectors, such x²+y²+z²+w²=1, keeping them inside 3-sphere.

the first problem solve rotation. figured out ordinary 3d rotation matrices suffice rotate world around viewer in 3d projection, since not mess w coordinate (pretty rotating sphere around z-axis rotate stereographic projection).

then figured out rotating along w-axis equivalent of translation inside 3d projection (just not commutative, ordinary 3d translations on "flat" spaces), translate along axis using simple around axis rotation matrix (x', y') = (x * cos - y * sin a, x * sin + y * cos a), variating w along axis.

this far got, , not figure out how navigate forward, based on position viewer facing projection. can apply inverse transform derive normalized 4-d vector (called f) viewer facing in hypersphere coordinates, don't know how navigate in direction using 4x4 matrix (what optimal in opengl). think on hackish solution: every vertex v, v' = normalize(d*f + v), d distance moved forward (in strange unit can not precise). way works small values of d, there no direct correlation between d , angle variation.

thus question is: how move forward (using 4x4 matrix transform) being in surface of 4-d hypersphere?

it turns out wrote papers in area time ago. 1 (interactive visualization methods 4 dimensions) applies closely particular problem other documents cite 1 may you. in particular application, rotating object being observed in 4d, not viewer, math equivalent.

regarding specific question:

thus question is: how move forward (using 4x4 matrix transform) being in surface of 4-d hypersphere?

if you're moving around on surface of hypersphere, aren't translating in w. need move in spherical geometry around great circle of unit radius. means that, if can construct appropriate axes frame of reference, can spherically interpolate between , going.

for example, 1 construction used such slerp use unit vector points straight ahead (your line of sight, aka p_1 in wikipedia equation), vector point out of top of head (p_0) , vector pointing out of right ear (to make right-handed coordinate system).

if tracking speed on sphere in angular velocity rather linear, can plug in value t (elapsed time) in wikipedia find new angular position.

note that equation places no limit on number of components in vertex p. spherical interpolation works in geometry.

edit (responding questions in comments):

slerp seems not case here, because not want interpolate rotation between 2 vectors on time. instead, @ each time step, want move every vertex opposite direction viewer moving @ moment. thus, @ position (0, 0, 0, 1) , want @ (sqrt(2)/2, sqrt(2)/2, 0, 0) next frame.

think of way: position on sphere (of dimension) vector displaces center surface. if you're moving around @ particular angular velocity, puts @ p0 , time t0, p1 @ time t1, etc. slerp handy way of calculating positions @ particular time.

likewise, line of sight vector @ right angles displacement vector. line of sight v0 @ time t0, v1 @ time t1 , forth. slerp again useful for calculating vector.

how can build correspondent transformation matrix, every vertex multiplied inverse of it?

using 2 vectors, orthogonalization gives third , have new reference frame. there single quaternion defines rotation original reference frame new one. that's looking for.

however, before can render world onto 2 dimensional screen, first need render down 4d 3d. opengl (unsurprisingly) not directly support this.

to see why, @ perspective projection matrix. assumes rendering homogenous points in 3d space: x, y, z in first 3 components , w (a scaling factor) in fourth. w = 0 indicates vector whereas w = else indicates point. w = other 1 non-normalized point.

so, there isn't way render point @ 4d origin of (0, 0, 0, 0).

as can see construction of matrix, however, isn't hard make 4d 3d projection matrix. apply first geometry set independently opengl's matrix pipeline. can use opengl standard matrices 3d screen.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -