hmm.. actually that doesnt work.
it does work for the traingle, but no matter what pitch, a is always the same, but i you calculate b, you are abled to find out the pitch.
so that comes out to this:
GeSHi (cpp):
D3DXVECTOR3 Terrain::GetSlope(float x,float y,float size,float zrot,float roll_distance,float pitch_distance)
{
float roll,pitch;
float middle=GetHeight(x,y,size);
pitch_distance*=((pitch_distance)/(sqrt(pow(pitch_distance*2,2)-pow(middle,2))));
roll_distance*=((roll_distance)/(sqrt(pow(roll_distance*2,2)-pow(middle,2))));
float heights[4]={GetHeight(x+cos(RAD(zrot))*pitch_distance,y-sin(RAD(zrot))*pitch_distance,size),
GetHeight(x-cos(RAD(zrot))*roll_distance,y-sin(RAD(zrot))*roll_distance,size),
GetHeight(x-cos(RAD(zrot))*pitch_distance,y+sin(RAD(zrot))*pitch_distance,size),
GetHeight(x+cos(RAD(zrot))*roll_distance,y+sin(RAD(zrot))*roll_distance,size)};
pitch=atan2(heights[2]-heights[0],pitch_distance*2);
roll=atan2(heights[3]-heights[1],roll_distance*2);
return D3DXVECTOR3(roll,pitch,zrot);
}
Created by GeSHI 1.0.7.18
i'm still debugging it so don't think it's working atm
(i'm just posting this in case someone needs it)
actually to get 150 posts but that doesnt care =3