You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At first it was kind of obvious that you can just use basic trig to get the hight of the triangle. But that comes into error when you have a z offset, or a y offset.
The code here is very simple, so I'll just break it down as such:
First you just see the trig function that this is based of off.
varlength = 10; // basically the hypotenuse of the triangle. vartheta = 45; // the angle of elevation, between the base and the hypotenuse varnewheight = sin(theta)*length;// This is the projected height, and as you can see, really primitive.
Taking a closer look at the issues with the one above, here is a list:
no offsets (in the y or z.)
y offset as in a tabletop, or something of the sort.
z offset as in a wall that needs to be at the opposite end of the screen, or a wall somewhere in the middle(but that doesnt make as much sense.)
working through the cons
Actually, they kind of come together.
working through the cons Working through the problem
When you are looking at the problem, you have a ground plane, and then you have the table top with the y and z offset.(I'm not worring abt the x offset because that doesnt change anything.(However it will be added in the complete solution.))
So. This is a tale of 2 triangles. You have the one on the bottom, and the one in between. The one of the bottom is the easy one.
varzOff = 10; // z offset w/ placeholder val varyOff = 10; // y off w/ placeholder val varfloorLength = 100; // length of the floor vartablelength = 30; // length of the table vartheta = 45; // angle of elevation varh1 = sin(theta)*zoff; // Using the same function as last time to get the bottom half. varh2 = cos(theta)*yoff; // Using cosine to get the between triangle.
Cons:
We still have these????
more of a feature, but walls need to have a ThetaOffset so that things can be tilted, or just having a vertical wall.
A really quick fix, but I like doing this kind of thing.
The math is simple, you just take the original code, and replace all of the thetas in lines 19 and 20 with thetaOffset-theta.
Here it is for those who want it:
varzOff = 10; // z offset w/ placeholder val varyOff = 10; // y off w/ placeholder val varfloorLength = 100; // length of the floor vartablelength = 30; // length of the table vartheta = 45; // angle of elevation varthetaOffset = 90; // vertical wallvarh1 = sin(thetaOffset-theta)*zoff; // Using the same function as last time to get the bottom half. varh2 = cos(theta)*yoff; // Using cosine to get the between triangle.