Given the x, y and z coordinates of three vectors, the task is to check if they are at equilibrium or not.
Input: x1 = -2, y1 = 1, z1 = 0, x2 = 5, y2 = 0, z2 = 5, x3 = -3, y3 = -1, z3 = -5
Output: The vectors are at equilibrium.
Input: x1 = 2, y1 = -17, z1 = 0, x2 = 5, y2 = 1, z2 = -5, x3 = 4, y3 = 2, z3 = -4
Output: The vectors are not at equilibrium.
When Three vectors are at equilibrium
Approach: Three vectors are at equilibrium when the results of those three vectors is a Null vector, i.e. it has no magnitude and direction. Resultant of three vectors is equal to the vector sum of the vectors. The resultant vector is Null when, ∑x = 0, ∑y = 0 and ∑ z = 0. Thus we can say that when the said condition satisfies then the vectors are at equilibrium and otherwise not.
# Python 3 program to check the
# equlibrium of three vectors
# Function to check the equlibrium
# of three vectors
def checkEqulibrium(x1, y1, z1, x2, y2,
z2, x3, y3, z3) :
# summing the x coordinates
resx = x1 + x2 + x3
# summing the y coordinates
resy = y1 + y2 + y3
# summing the z coordinates
resz = z1 + z2 + z3
# Checking the condition for equlibrium
if (resx == 0 and resy == 0 and
resz == 0):
# Driver code
x1 = -2; y1 = -7; z1 = -9
x2 = 5; y2 = -14; z2 = 14
x3 = -3; y3 = 21; z3 = -5
# Checking for equlibrium
if (checkEqulibrium(x1, y1, z1,
x2, y2, z2,
x3, y3, z3)):
print(“The vectors are at equilibrium.”)
print(“The vectors are not at equilibrium.”)
# This code is contributed
# by Akanksha Rai
The vectors are at equilibrium.
- Find area of parallelogram if vectors of two adjacent sides are given
- Find area of triangle if two vectors of two adjacent sides are given
- Program for dot product and cross product of two vectors
- Check n^2 - m^2 is prime or not
- Check whether a given number is even or odd
- Check divisibility by 7
- Check whether a given matrix is orthogonal or not
- Check whether Bishop can take down Pawn or not
- Check whether XOR of all numbers in a given range is even or odd
- Check if two numbers are co-prime or not
- Check whether a + b = c or not after removing all zeroes from a,b and c
- Check if N is a Factorial Prime
- Check if N is Strong Prime
- Check for Amicable Pair
- Check whether a number is semiprime or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.