- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find area of triangle if two vectors of two adjacent sides are given using C++
Suppose we have two vectors for two adjacent sides of a triangle in the form $x\hat{i}+y\hat{j}+z\hat{k}$ Our task is to find the area of triangle. The area of triangle is magnitude of the cross product of two vectors. (|A x B|)
$$\frac{1}{2}\rvert \vec{A}\times\vec{B}\rvert=\frac{1}{2}\sqrt{\lgroup y_{1}*z_{2}-y_{2}*z_{1}\rgroup^{2}+\lgroup x_{1}*z_{2}-x_{2}*z_{1}\rgroup^{2}+\lgroup x_{1}*y_{2}-x_{2}*y_{1}\rgroup^{2}}$$
Example
#include<iostream> #include<cmath> using namespace std; float area(float A[], float B[]) { float area = sqrt(pow((A[1] * B[2] - B[1] * A[2]),2) + pow((A[0] * B[2] - B[0] * A[2]),2) + pow((A[0] * B[1] - B[0] * A[1]),2)); return area*0.5; } int main() { float A[] = {3, 1, -2}; float B[] = {1, -3, 4}; float a = area(A, B); cout << "Area = " << a; }
Output
Area = 8.66025
- Related Articles
- Find area of parallelogram if vectors of two adjacent sides are given using C++.
- Two adjacent sides of a triangle are $3x^2-5y^2$ and $7x^2-xy$. Find its perimeter.
- Find the hypotenuse of a right angled triangle with given two sides in C++
- Draw a rough sketch of a quadrilateral KLMN. State,(a) two pairs of opposite sides,(b) two pairs of opposite angles,(c) two pairs of adjacent sides,(d) two pairs of adjacent angles.
- Find other two sides of a right angle triangle in C++
- Corresponding sides of two similar triangles are in the ratio of $2 : 3$. If the area of the smaller triangle is $48 cm 2$, then find the area of the larger triangle.
- Corresponding sides of two similar triangles are in the ratio of ( 2: 3 ). If the area of the smaller triangle is ( 48 mathrm{~cm}^{2} ), find the area of the larger triangle.
- Which of the following statements are true (T) and which are false (F):If any two sides of a right triangle are respectively equal to two sides of other right triangle, then the two triangles are congruent.
- Find other two sides and angles of a right angle triangle in C++
- Golang Program to Find the Area of a Triangle Given All Three Sides
- Find the area of a triangle two sides of which are $18 cm$ and $10 cm$ and the perimeter is $42 cm$.
- How to find the perimeter of a parallelogram with two adjacent sides of 18 and 20cm?
- Two sides and the perimeter of one triangle are respectively three times the corresponding sides and the perimeter of the other triangle. Are the two triangles similar? Why?
- Is it true to say that if in two triangles, an angle of one triangle is equal to an angle of another triangle and two sides of one triangle are proportional to the two sides of the other triangle, then the triangles are similar? Give reasons for your answer.
- Find the area of a triangle two sides of which are 18 cm and ( 10 mathrm{~cm} ) and the perimeter is ( 42 mathrm{~cm} ).

Advertisements