Kindly refer to the images for the instructions (Python language) Code Template: class Vector3D: def __init__(self, x, y, z): # TODO: Create a routine that saves the vector # into this Vector3D...


Kindly refer to the images for the instructions (Python language)


Code Template:


class Vector3D:
    def __init__(self, x, y, z):
          # TODO: Create a routine that saves the vector
        # into this Vector3D object.
        pass

    def __add__(self, other):
        # TODO: Create a routine that adds this vector with Vector3D other
        #       and returns the result as a Vector3D object

        return None


    def __neg__(self):
        # TODO: Create a routine that returns the negative (opposite) of
        #       this vector as a Vector3D object


        return None


    def __sub__(self, other):
        # TODO: Create a routine that subtracts this vector with Vector3D other
        #       and returns the result as a Vector3D object

        return None


    def __mul__(self, other):
        # TODO: Create a routine that multiplies this vector with other
        #       depending on its data type, and returns the result as a
        #       Vector3D object. other can either be an integer
        #       scalar or a Vector3D object.


        return None


def main():
    testcases = int(input())


    for t in range(testcases):
        line_in = input().split()
        op = line_in[0].strip()
        vec_vals = [int(x) for x in line_in[1:]]


        # TODO: a Write routine that processes a line in the input
        # op       - string
        #          - operation to do with the provided vectors
        #          - can only be one from the set: {add, sub, neg, mul_s, mul}
        # vec_vals - list of integers
        #          - numbers that follow the op in the input line
        #          - can only have a length of 3, 4, or 6


if __name__ == '__main__':
    main()


3D graphic design is a relatively new but exciting field, especially with the advent of the metaverse and virtual<br>reality. However, before the current advancements came into existence, somebody had to study the<br>underlying
as such: Vector3D(x, y, z). In addition, you are required to write Vector3D in terms of special functions so that programmers could more expressively write their code. For example, if you have two 3D vectors a and b, programmers should be able to write a + b (the same as a._add__ (b) ) in their programs. For testing purposes, you have generated a file containing a list of operations to execute and the operands to use, which can either be a 3D vector or scalar depending on the operation. Input Format The first line of the input is an integer T denoting the number of lines that will follow. Each line then consists of a variable number of elements separated by a space. The line starts with a word op denoting what operation to do. The operations will only be any of the following: add, sub, neg. mul_s, mul.The next elements will be space-separated numbers. For add, sub, and mul, op will be followed by six numbers a, a, a, b, by bz corresponding to the coordinates of vectors a and b respectively., For mul_s, op will be followed by four numbers a, ay az s corresponding to the coordinates of the vector a and a scalar s, respectively. For neg, op will be followed by three numbers a, a, a, corresponding to the coordinates of the vector a. "/>
Extracted text: 3D graphic design is a relatively new but exciting field, especially with the advent of the metaverse and virtual reality. However, before the current advancements came into existence, somebody had to study the underlying "hard" math and implement everything into a computer. The basic unit of a 3D graphic is a 3D point or vector A, which is a tuple of three numbers (az, ay, az). Such a tuple represents a location in 3D space, which can additionally be interpreted as a vector pointing from the origin (0, 0, 0) to A. Being a contributor for the Numeric library in Python in the late 1990s, you took on the task to implement a 3D vector and its basic operations. More specifically, you will be implementing a class Vector3D that contains three integer coordinates, and supports the following operations: • vector addition ( add) subtraction ( sub) • negation ( neg) • element-wise multiplication ( mul) • scalar multiplication (mul_s). This Vector3D can be initialized by providing the 3D coordinates < x,="" y,="" z=""> as such: Vector3D(x, y, z). In addition, you are required to write Vector3D in terms of special functions so that programmers could more expressively write their code. For example, if you have two 3D vectors a and b, programmers should be able to write a + b (the same as a._add__ (b) ) in their programs. For testing purposes, you have generated a file containing a list of operations to execute and the operands to use, which can either be a 3D vector or scalar depending on the operation. Input Format The first line of the input is an integer T denoting the number of lines that will follow. Each line then consists of a variable number of elements separated by a space. The line starts with a word op denoting what operation to do. The operations will only be any of the following: add, sub, neg. mul_s, mul.The next elements will be space-separated numbers. For add, sub, and mul, op will be followed by six numbers a, a, a, b, by bz corresponding to the coordinates of vectors a and b respectively., For mul_s, op will be followed by four numbers a, ay az s corresponding to the coordinates of the vector a and a scalar s, respectively. For neg, op will be followed by three numbers a, a, a, corresponding to the coordinates of the vector a.
Constraints<br>Input Constraints<br>T< 100<br>A = (ap, ay, az) E Z³. {a; € Z : [a;| < 10°}<br>op € {add, sub, neg, mul, mul_s}<br>Max running time of code should be s 5 seconds for each test input.<br>You can assume that all of the inputs are well-formed and are always provided within these constraints. You<br>are not required to handle any errors.<br>Functional Constraints<br>You are required to create a class named Vector3D with an _init_ (self, x, y, z) function. It should<br>also have the following special functions: -_add__, -_sub_, -_neg__, -_mul_. Failure to do so will mark<br>your code with a score of zero.<br>Output Format<br>The output consists of T lines, with each line i corresponding to the 3D vector a ajy aj,z that is the result<br>of performing the operation requested on that line.<br>Sample Input 0<br>add 1 2 3 4 5 6<br>23 4 5 6<br>sub 1<br>mul_s 1 2 3 -2<br>mul 1 2 3 4 5 6<br>neg 3 3 3<br>Sample Output 0<br>5 7 9<br>-3 -3 -3<br>-2 -4 -6<br>4 10 18<br>-3 -3 -3<br>

Extracted text: Constraints Input Constraints T< 100="" a="(ap," ay,="" az)="" e="" z³.="" {a;="" €="" z="" :="" [a;|="">< 10°} op € {add, sub, neg, mul, mul_s} max running time of code should be s 5 seconds for each test input. you can assume that all of the inputs are well-formed and are always provided within these constraints. you are not required to handle any errors. functional constraints you are required to create a class named vector3d with an _init_ (self, x, y, z) function. it should also have the following special functions: -_add__, -_sub_, -_neg__, -_mul_. failure to do so will mark your code with a score of zero. output format the output consists of t lines, with each line i corresponding to the 3d vector a ajy aj,z that is the result of performing the operation requested on that line. sample input 0 add 1 2 3 4 5 6 23 4 5 6 sub 1 mul_s 1 2 3 -2 mul 1 2 3 4 5 6 neg 3 3 3 sample output 0 5 7 9 -3 -3 -3 -2 -4 -6 4 10 18 -3 -3 -3 10°}="" op="" €="" {add,="" sub,="" neg,="" mul,="" mul_s}="" max="" running="" time="" of="" code="" should="" be="" s="" 5="" seconds="" for="" each="" test="" input.="" you="" can="" assume="" that="" all="" of="" the="" inputs="" are="" well-formed="" and="" are="" always="" provided="" within="" these="" constraints.="" you="" are="" not="" required="" to="" handle="" any="" errors.="" functional="" constraints="" you="" are="" required="" to="" create="" a="" class="" named="" vector3d="" with="" an="" _init_="" (self,="" x,="" y,="" z)="" function.="" it="" should="" also="" have="" the="" following="" special="" functions:="" -_add__,="" -_sub_,="" -_neg__,="" -_mul_.="" failure="" to="" do="" so="" will="" mark="" your="" code="" with="" a="" score="" of="" zero.="" output="" format="" the="" output="" consists="" of="" t="" lines,="" with="" each="" line="" i="" corresponding="" to="" the="" 3d="" vector="" a="" ajy="" aj,z="" that="" is="" the="" result="" of="" performing="" the="" operation="" requested="" on="" that="" line.="" sample="" input="" 0="" add="" 1="" 2="" 3="" 4="" 5="" 6="" 23="" 4="" 5="" 6="" sub="" 1="" mul_s="" 1="" 2="" 3="" -2="" mul="" 1="" 2="" 3="" 4="" 5="" 6="" neg="" 3="" 3="" 3="" sample="" output="" 0="" 5="" 7="" 9="" -3="" -3="" -3="" -2="" -4="" -6="" 4="" 10="" 18="" -3="" -3="">
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here