I'm trying to make a 3D terrain generator. In doing so, I decided that I would use basic rectangles and then just turn them by having 4 points, 1 on each side, then turn the rectangle to fit in those points. Now when I try to make it so that it can decide a new point, with the distance being the length of the new rectangle ( which all rectangles are congruent so it'll stay the same ) and the slope of the 2D line between the bricks will be a randomly picked number ( Math.random()*3-3 ) so I tried to solve it like this
sizeOfRectangle=(X-oldPoint.X)*new_slope
then came out like this
X=sizeOfRectangle/new_slope+oldPoint.X
then find the y-intercept
B=oldPoint.Y-(new_slope*oldPoint.X)
then I would plug in X to the 2D equation of a line
Y=new_slope*X+B
yet for some reason all the rectangles would come out facing either 90 or 180 degree angles. Did I do my math wrong or is it some other error I made?
I'm having trouble following your explanations (and it looks like I'm not the only one), but the general term for the kind of algorithm I think you're trying to implement (and the kind which lewellen describes) is "midpoint displacement". Google for it.
Ps. As Jyrki notes in the comments, a minor problem with using rectangles for this kind of algorithm is that, in general, four random points in 3D space will not be coplanar. Using triangles (and repeatedly subdividing each of them into four sub-triangles) avoids this problem, although of course one may also work on a rectangular lattice (as in the "diamond–square" algorithm) and only finally subdivide rectangles into triangles if and as needed.