Assignment 2 Problems - Computer Programing with Engineering Application | CS 2073, Assignments of Computer Science

Material Type: Assignment; Class: Comp Prog W/Egr Application; Subject: Computer Science; University: University of Texas - San Antonio; Term: Spring 2009;

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-lvy
koofers-user-lvy 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 2073-001 Computer Programming
with Engineering Applications
Spring 2009
Instructor Dr. Turgay Korkmaz
sample problem
Background: General equation for a line is Ax + By + C = 0 (A, B, C are const).
Suppose we have two different lines A1x + B1y + C1 = 0 and A2x + B2y + C2 = 0.
To find the intersection point of these lines and the angle between them, we can use the
following formulas:
22
11
22
11
0
BA
BA
CB
CB
x
and
22
11
22
11
0
BA
BA
AC
AC
y
and
Note that
22
11
BA
BA
means Determinant and computed as A1*B2 - A2*B1
HW Question:
Write a program that asks user to enter A1, B1, C1 for the first line and A2, B2, C2
for the second line, and then
1. the program first computes the intersection point x0 and y0 and prints them
then
2. it finds the angle between the lines and prints it in degree. (you need to solve that
problem, the above formula of cos(angle)=… will help but you need to consider its
inverse. Also we want angle in degrees (note that cos in C assumes that angle is in
radians).
If
22
11
BA
BA
== 0 holds, the lines are parallel.

Partial preview of the text

Download Assignment 2 Problems - Computer Programing with Engineering Application | CS 2073 and more Assignments Computer Science in PDF only on Docsity!

CS 2073-001 Computer Programming

with Engineering Applications

Spring 2009 Instructor Dr. Turgay Korkmaz sample problem Background: General equation for a line is Ax + By + C = 0 (A, B, C are const). Suppose we have two different lines A1x + B1y + C1 = 0 and A2x + B2y + C2 = 0. To find the intersection point of these lines and the angle between them, we can use the following formulas: 2 2

0 A B

A B

B C

B C

x  (^) and 2 2

0 A B

A B

C A

C A

y  (^) and Note that (^22)

A B

A B

means Determinant and computed as A1B2 - A2B

HW Question:

Write a program that asks user to enter A1, B1, C1 for the first line and A2, B2, C

for the second line, and then

1. the program first computes the intersection point x0 and y0 and prints them

then

  1. it finds the angle between the lines and prints it in degree. (you need to solve that problem, the above formula of cos(angle)=… will help but you need to consider its inverse. Also we want angle in degrees (note that cos in C assumes that angle is in radians). If 2 2

A B

A B

== 0 holds, the lines are parallel.