Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using python Create a class to handle x,y,z vectors. The class should have the following features 1) create a vector using v = myvector(x,y,z) to

using python

Create a class to handle x,y,z vectors. The class should have the following features

1) create a vector using v = myvector(x,y,z) to initialize the vector

2) find the magnitude of the vector v.mag() returns the magnitude

2) add two vectors so v1=myvector(x,y,z) v2=myvector(x,y,z) v3 = v1+v2

3) v.format() returns a string of the form xi + yj + zk

4) perform cross product when vectors are multiplied v3 = v1 * v2 v3 is the cross product v1 and v2

5) Challenge: does vector scaling so v3 = v1*10 returns a vector 10 time v1. This feature must not interfere with (4) above.

Program structure

complex class definition here...

# ------------- Main -----------

a = vector(1,2,1)

b = vector(4,1,7)

print(a.format(), "Mag = ", a.mag())

print(b.format(), "Mag = ", b.mag())

print("a + b =", (a.add(b)).format())

print("a cross b = ", (a.cross(b)).format())

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago