Can you improve my scaling function?

BlitzMax Forums/BlitzMax Programming/Can you improve my scaling function?

meems(Posted 2016) [#1]
Hi lads,
Bit of a specialist question here.

I while back I wrote my own quaternion 3D engine, which did rotations on a sphere.

Now I'd like to add a scaling function, so that images draped onto the sphere can be stretched.

I've already got one, but I think its inefficient.

current method.
1. Rotate image so that its centre of area is over the pole.
2. Mulitply latitude co-ordinates of image by a fraction
3. Rotate image back to its original position

This 3 step method totally works. But with quaternions there's often a clever trick to do things much easier. Does anyone know a simpler method?

For simplicity, just assume its a homogeneous stretch, i.e. stretch same in all directions.

I'd try figure it out myself usually but I've too little time these days.


Floyd(Posted 2016) [#2]
Well, quaternions are rotations so intuitively it seems unlikely you can use them for anything else.

And they operate on the 3D object, not the texture. I would think the scaling you describe comes down to scaling u-v coordinates. That assumes we are talking about u-v mapped spheres rather than some custom designed system.

It's also not clear what results you would get. Simple scaling probably works well enough for very small changes, say a few percent. But for anything substantial the resulting distortion will be more obvious. There is no way to map a flat 2D image so it correspond to points on a sphere without some kind of distortion. That's why there are different kinds of projections for various maps of the earth, depending on what kind of error is acceptable. For example, the common Mercator's projection works nicely for regions not too far from the equator. But the north end of Greenland is very wrong, looks much larger than it really is.

That's going the opposite direction, projecting a region of a sphere onto a flat image. But similar considerations apply either way.


meems(Posted 2016) [#3]
Well, quaternions are rotations so intuitively it seems unlikely you can use them for anything else.

yes u could be right there. Oh well. Maybe I discovered the ultimate way to stretch objects the 1st time I tried. I can't help it if I really am that amazing.