But using this to find the corners and edges of squashed cube does not work, because I don't know how to control the scaling change for squashed sphere to match the scaling of a squashed cube.
Once again, I am asking the math wizards to step in and give me a helping hand...

To try this out, just drop this script into a perfect cube (uniform size, x=y=z), along with a small prim named "Marker", and click on the cube:
CODE
// Sphere rotation equations by: Strife Onizuka
// Generalized functions for cubes by: Scalar Tardis
//
// See thread in SL forum: Scripting Tips
// http://forums.secondlife.com/showthread.php?p=1323456
//
vector PointOnSphereLocVec(vector vSphereSize, vector vSpherePos,
rotation rSphereRot, vector vLocalVector)
{
// llGetScale() returns prim diameter, but this equation
// assumes it's a radius, so divide size in half
vSphereSize.x /= 2; vSphereSize.y /= 2; vSphereSize.z /= 2;
vector vt = vLocalVector * <0.0,0.0,0.0,1.0>;
return vSpherePos + (vt / llVecMag(<vt.x / vSphereSize.x, vt.y
/ vSphereSize.y, vt.z / vSphereSize.z>)) * rSphereRot;
}
vector PointOnSphereLocRot(vector vSphereSize, vector vSpherePos,
rotation rSphereRot, rotation rLocalRot)
{
// llGetScale() returns prim diameter, but this equation
// assumes it's a radius, so divide size in half
vSphereSize.x /= 2; vSphereSize.y /= 2; vSphereSize.z /= 2;
vector vt = <0.0,0.0,-1.0> * rLocalRot;
return vSpherePos + (vt / llVecMag(<vt.x / vSphereSize.x, vt.y
/ vSphereSize.y, vt.z / vSphereSize.z>)) * rSphereRot;
}
vector CubeEdgeCenterLocVec(vector vSphereSize, vector vSpherePos,
rotation rSphereRot, vector vLocalVector)
{
// llGetScale() returns prim diameter, but this equation
// assumes it's a radius, so divide size in half
vSphereSize.x /= 2; vSphereSize.y /= 2; vSphereSize.z /= 2;
// The size difference between a cube and a sphere that
// touches the center of the edges is 1.414214
vSphereSize.x *= 1.414214;
vSphereSize.y *= 1.414214;
vSphereSize.z *= 1.414214;
vector vt = vLocalVector * <0.0,0.0,0.0,1.0>;
return vSpherePos + (vt / llVecMag(<vt.x / vSphereSize.x, vt.y
/ vSphereSize.y, vt.z / vSphereSize.z>)) * rSphereRot;
}
vector CubeEdgeCenterLocRot(vector vSphereSize, vector vSpherePos,
rotation rSphereRot, rotation rLocalRot)
{
// llGetScale() returns prim diameter, but this equation
// assumes it's a radius, so divide size in half
vSphereSize.x /= 2; vSphereSize.y /= 2; vSphereSize.z /= 2;
// The size difference between a cube and a sphere that
// touches the center of the edges is 1.414214
vSphereSize.x *= 1.414214;
vSphereSize.y *= 1.414214;
vSphereSize.z *= 1.414214;
vector vt = <0.0,0.0,-1.0> * rLocalRot;
return vSpherePos + (vt / llVecMag(<vt.x / vSphereSize.x, vt.y
/ vSphereSize.y, vt.z / vSphereSize.z>)) * rSphereRot;
}
vector CubeCornersLocVec(vector vSphereSize, vector vSpherePos,
rotation rSphereRot, vector vLocalVector)
{
// llGetScale() returns prim diameter, but this equation
// assumes it's a radius, so divide size in half
vSphereSize.x /= 2; vSphereSize.y /= 2; vSphereSize.z /= 2;
// The size difference between a cube and a sphere that
// touches the center of the edges is 1.7320508
vSphereSize.x *= 1.7320508;
vSphereSize.y *= 1.7320508;
vSphereSize.z *= 1.7320508;
vector vt = vLocalVector * <0.0,0.0,0.0,1.0>;
return vSpherePos + (vt / llVecMag(<vt.x / vSphereSize.x, vt.y
/ vSphereSize.y, vt.z / vSphereSize.z>)) * rSphereRot;
}
vector CubeCornersLocRot(vector vSphereSize, vector vSpherePos,
rotation rSphereRot, rotation rLocalRot)
{
// llGetScale() returns prim diameter, but this equation
// assumes it's a radius, so divide size in half
vSphereSize.x /= 2; vSphereSize.y /= 2; vSphereSize.z /= 2;
// The size difference between a cube and a sphere that
// touches the center of the edges is 1.414214
vSphereSize.x *= 1.7320508;
vSphereSize.y *= 1.7320508;
vSphereSize.z *= 1.7320508;
vector vt = <0.0,0.0,-1.0> * rLocalRot;
return vSpherePos + (vt / llVecMag(<vt.x / vSphereSize.x, vt.y
/ vSphereSize.y, vt.z / vSphereSize.z>)) * rSphereRot;
}
default
{ state_entry()
{ llSay(0, "Ready."); }
touch_start(integer total_number)
{
llSay(0, "Starting..");
vector MyScale = llGetScale();
vector MyPos = llGetPos();
rotation MyRot = llGetRot();
vector VecOffset;
vector coords;
llSay(0, "My Position:" + (string)MyPos );
llSay(0, "My Scale:" + (string)MyScale);
// Here are all valid cube face-centers for a perfect
// cube with a Euler-format rotation of 0°, 0°, 0°
//
// <-1.0, 0.0, 0.0>; = -x
// < 1.0, 0.0, 0.0>; = +x
// < 0.0,-1.0, 0.0>; = -y
// < 0.0, 1.0, 0.0>; = +y
// < 0.0, 0.0,-1.0>; = -z
// < 0.0, 0.0,-1.0>; = +z
VecOffset = ZERO_VECTOR;
for (VecOffset.x = -1; VecOffset.x <= 1; VecOffset.x += 2)
{
coords = PointOnSphereLocVec(MyScale, MyPos, MyRot, VecOffset);
llRezObject ("Marker", coords, ZERO_VECTOR, ZERO_ROTATION, 1);
}
VecOffset = ZERO_VECTOR;
for (VecOffset.y = -1; VecOffset.y <= 1; VecOffset.y += 2)
{
coords = PointOnSphereLocVec(MyScale, MyPos, MyRot, VecOffset);
llRezObject ("Marker", coords, ZERO_VECTOR, ZERO_ROTATION, 1);
}
VecOffset = ZERO_VECTOR;
for (VecOffset.z = -1; VecOffset.z <= 1; VecOffset.z += 2)
{
coords = PointOnSphereLocVec(MyScale, MyPos, MyRot, VecOffset);
llRezObject ("Marker", coords, ZERO_VECTOR, ZERO_ROTATION, 1);
}
// Here are all valid cube edge-centers for a perfect
// cube with a Euler-format rotation of 0°, 0°, 0°
//
// ** "bottom" four:
// <-1.0, 0.0,-1.0>; = -x, 0, -z
// < 1.0, 0.0,-1.0>; = +x, 0, -z
// < 0.0,-1.0,-1.0>; = 0, -y, -z
// < 0.0, 1.0,-1.0>; = 0, +y, -z
// ** "middle" four:
// <-1.0,-1.0, 0.0>; = -x, -y, 0
// <-1.0, 1.0, 0.0>; = -x, -y, 0
// < 1.0,-1.0, 0.0>; = x, +y, 0
// < 1.0, 1.0, 0.0>; = x, +y, 0
// ** "top" four:
// <-1.0, 0.0, 1.0>; = -x, 0, +z
// < 1.0, 0.0, 1.0>; = +x, 0, +z
// < 0.0,-1.0, 1.0>; = 0, -y, +z
// < 0.0, 1.0, 1.0>; = 0, +y, +z
integer stepz;
integer negflip;
integer xyflip;
for (stepz = -1; stepz <= 1; stepz += 2)
{
for (negflip = -1; negflip <= 1; negflip += 2)
{
for (xyflip = 0; xyflip <= 1; xyflip += 1)
{
VecOffset.x = negflip * xyflip;
VecOffset.y = negflip * (1 - xyflip);
VecOffset.z = stepz;
coords = CubeEdgeCenterLocVec(MyScale, MyPos, MyRot, VecOffset);
llRezObject ("Marker", coords, ZERO_VECTOR, ZERO_ROTATION, 1);
}
}
}
VecOffset.z = 0;
for (VecOffset.x = -1; VecOffset.x <= 1; VecOffset.x += 2)
{
for (VecOffset.y =-1; VecOffset.y <= 1; VecOffset.y += 2)
{
coords = CubeEdgeCenterLocVec(MyScale, MyPos, MyRot, VecOffset);
llRezObject ("Marker", coords, ZERO_VECTOR, ZERO_ROTATION, 1);
}
}
// Here are all valid cube corners for a perfect
// cube with a Euler-format rotation of 0°, 0°, 0°
//
// ** "bottom" four corners:
// <-1.0,-1.0,-1.0>; = -x, -y, -z
// <-1.0, 1.0,-1.0>; = -x, +y, -z
// < 1.0,-1.0,-1.0>; = +x, -y, -z
// < 1.0, 1.0,-1.0>; = +x, +y, -z
// ** "top" four corners:
// <-1.0,-1.0, 1.0>; = -x, -y, +z
// <-1.0, 1.0, 1.0>; = -x, +y, +z
// < 1.0,-1.0, 1.0>; = +x, -y, +z
// < 1.0, 1.0, 1.0>; = +x, +y, +z
for (VecOffset.x = -1; VecOffset.x <= 1; VecOffset.x += 2)
{
for (VecOffset.y = -1; VecOffset.y <= 1; VecOffset.y += 2)
{
for (VecOffset.z = -1; VecOffset.z <= 1; VecOffset.z += 2)
{
coords = CubeCornersLocVec(MyScale, MyPos, MyRot, VecOffset);
llRezObject ("Marker", coords, ZERO_VECTOR, ZERO_ROTATION, 1);
}
}
}
}
}