To make an angle you need two intersecting lines, don't you?
But for what I assume you want, you could do the easy way (place a sprite at the first point, make it point towards the second point, and store the direction in a variable to get the direction of the parallel line), or the complex but efficient way, with this script:
Just make a sprite move in the direction this script calculates to get a parallel line.
Last edited by Kileymeister (2011-01-29 09:55:20)
Offline
rep353 wrote:
Thanks for that post the easy part was useful and easy to understand. Could you please briefly explain the second (harder) way as it has so many if and else statements :S
Sure, this is getting into a bit complex stuff, you don't need to understand it all (you can just recreate the script and plug it in) but here's a short explanation.
The Main Part of the Script
Basically the main part of that script is the bottom half of the first if else piece. Atan is a mathematical function, you don't need to know the exact function, but atan of x1-x2/y1-y2 gets direction out of a slope.
The reason there are two atans is because atan always turns out facing above 90 or -90 degrees, so for when the sprite needs to be facing down or below 90 or -90 degrees you rotate it 180 degrees (makes the sprite face backwards). So if y1-y2 is less than 0 (meaning the line is going down) it turns 180 degrees.
The top half of the first if else script
The purpose of the top half of the first if else script is to make sure y1-y2 is not 0. If it is 0, the atan part won't work because you need to divide a number by y1-y2 and you cannot divide by 0.
Because y1-y2=0 means the sprites are on the same vertical position, the sprite is only going to face right or left. So it checks if the line is going right or left and faces that direction.
The point in direction 0 (up) part is for when both points of the line are in the exact same place. This will rarely happen but when it does the sprite will just point up.
--------
Ok, that's a lot to chew, and is a bit confusing in some parts, but as I said you don't need to know all of this right now, you have plenty of time to learn.
Last edited by Kileymeister (2011-01-29 11:32:09)
Offline
kayybee wrote:
rep353 wrote:
Hey guys I have 2 points which I can get the slope of [m = y2 -y1 / x2 -x1]
Congratulations! You remember your algebra!
![]()
Algebra? Isn't that Geometry?
Offline
mathematics wrote:
kayybee wrote:
rep353 wrote:
Hey guys I have 2 points which I can get the slope of [m = y2 -y1 / x2 -x1]
Congratulations! You remember your algebra!
![]()
Algebra? Isn't that Geometry?
I think it is usually taught in Algebra, but is also used in Geometry.
Offline
scmb1 wrote:
mathematics wrote:
kayybee wrote:
Congratulations! You remember your algebra!
![]()
Algebra? Isn't that Geometry?
I think it is usually taught in Algebra, but is also used in Geometry.
I'm in algebra.
That's taught in Pre-algebra.
The algebra ones are standard:
Ax+By= C
And Point-Slope:
y-y1=m(x-x1)
Offline
bbbeb wrote:
scmb1 wrote:
mathematics wrote:
Algebra? Isn't that Geometry?I think it is usually taught in Algebra, but is also used in Geometry.
I'm in algebra.
That's taught in Pre-algebra.
![]()
The algebra ones are standard:
Ax+By= C
And Point-Slope:
y-y1=m(x-x1)
![]()
I guess it depends on your school. I don't remember when I learned it.
Offline
bbbeb wrote:
scmb1 wrote:
mathematics wrote:
Algebra? Isn't that Geometry?I think it is usually taught in Algebra, but is also used in Geometry.
I'm in algebra.
That's taught in Pre-algebra.
![]()
The algebra ones are standard:
Ax+By= C
And Point-Slope:
y-y1=m(x-x1)
![]()
Also, y=mx+b
Offline
scmb1 wrote:
bbbeb wrote:
scmb1 wrote:
I think it is usually taught in Algebra, but is also used in Geometry.
I'm in algebra.
That's taught in Pre-algebra.
![]()
The algebra ones are standard:
Ax+By= C
And Point-Slope:
y-y1=m(x-x1)
![]()
I guess it depends on your school.
I don't remember when I learned it.
We did slope of a line as trigonometry. The slope of a line is easy but there's some other stuff a lot more tricky to do. I'm doing higher level maths for my leaving cert (in Ireland) so I get to learn a lot of things in maths but trigonometry is the only thing I find useful.
Last edited by rep353 (2011-01-30 16:25:49)
Offline
this shizzies dont make sense whats a slope and what an atum whats with all the math,,, i just copied the velocity movment but i didnt get it in the first place some one plaz answer this
Offline
jazed13 wrote:
this shizzies dont make sense whats a slope and what an atum whats with all the math,,, i just copied the velocity movment but i didnt get it in the first place some one plaz answer this
I'll assume you're younger and haven't taken some more advanced classes.
Slope is the ratio a line plotted on a linear graph moves vertically/horizontally. However far a line moves vertically each time it goes horizontal 1 unit determines the slope. It can also be written rise/run.
An atom (I'll assume you meant that) is a unit of matter so vastly small you can't see it. It is considered the smallest unit if you don't count the subatomic particles that hold it together. Atoms combine to make molecules, which combine to make larger units. Everything is made from atoms.
Last edited by Kileymeister (2011-02-01 13:08:11)
Offline
Kileymeister wrote:
jazed13 wrote:
this shizzies dont make sense whats a slope and what an atum whats with all the math,,, i just copied the velocity movment but i didnt get it in the first place some one plaz answer this
I'll assume you're younger and haven't taken some more advanced classes.
Slope is the ratio a line plotted on a linear graph moves vertically/horizontally However far a line moves vertically each time it goes horizontal 1 unit determines the slope. It can also be written rise/run.
An atom (I'll assume you meant that) is a unit of matter so vastly small you can't see it. It is considered the smallest unit if you don't count the subatomic particles that hold it together. Atoms combine to make molecules, which combine to make larger units. Everything is made from atoms.
Or, simply.
Slope = amount of change
Amount of rise
-------------------
Amount of run
Atom = 2nd most smallest unit of matter.
Offline
bbbeb wrote:
Kileymeister wrote:
jazed13 wrote:
this shizzies dont make sense whats a slope and what an atum whats with all the math,,, i just copied the velocity movment but i didnt get it in the first place some one plaz answer this
I'll assume you're younger and haven't taken some more advanced classes.
Slope is the ratio a line plotted on a linear graph moves vertically/horizontally However far a line moves vertically each time it goes horizontal 1 unit determines the slope. It can also be written rise/run.
An atom (I'll assume you meant that) is a unit of matter so vastly small you can't see it. It is considered the smallest unit if you don't count the subatomic particles that hold it together. Atoms combine to make molecules, which combine to make larger units. Everything is made from atoms.Or, simply.
Slope = amount of change
Amount of rise
-------------------
Amount of run
Atom = 2nd most smallest unit of matter.
Quark= 1st smallest.
Also, I think jazed13 meant "What does atan mean", not atom.
Offline
ian528 wrote:
Also, I think jazed13 meant "What does atan mean", not atom.
![]()
Oh, you're probably right. Let me break that down too.
Atan is the inverse of the function tangent.
Tangent takes the amount in degrees of an angle of a triangle and gives you the length of the opposite side to the angle divided by the adjacent side to the angle, without using the hypotenuse.
Atan (written correctly as tan^-1), being tangent's inverse, takes the length of the opposite side to the angle divided by the adjacent side to the angle to get the amount in degrees of the angle.
In scratch atan and tangent are used often for direction equations.
Last edited by Kileymeister (2011-02-01 16:36:02)
Offline