# Problem Set 106

Complete the problems described below.

Submit your work via email. A special email address has been setup for this purpose, and you can attach whatever files are appropriate to any mail sent to the address below. So I can tell which files below to whom, please **title all submitted files as**:

    LASTNAME firstname.py

Submit this file to the class file submission email:

    SUBMITT.6g9n8dakvpw0bkft@u.box.com
    


```python
from decodes.core import *
from decodes.io.jupyter_out import JupyterOut
out = JupyterOut.two_pi( )
from math import *
```

## Lines and Planes in Cartesian Space

#### 106.01

We may plot a point $P$ on a given line if provided three quantities: an origin Point $\vec{p_{0}}$, a Vec direction $\vec{v}$, and a parameter along the line at which to find the desired Point $t$. In vector notation, this may be written as follows. In each of the scenarios below, using just the wits that your mother gave you (no coding), find the value of $P$

\begin{align}
P = \vec{p_{0}} + t\vec{v}
\end{align}

Note that in the code shown below, for scenario x, `p_origin_x` is the origin Point $\vec{p_{0}}$, `vec_x` is the Vec $\vec{v}$, and `t_x` is the required parameter.


```python
p_origin_a, vec_a, t_a = Point(), Vec(1,0), 1
# construct a new point here using coordinates corresponding to a point that results from the evaluation of the line above
pa = ???

p_origin_b, vec_b, t_b = Point(), Vec(1,1), 0.5
# construct a new point here using coordinates corresponding to a point that results from the evaluation of the line above
pb = ???

p_origin_c, vec_c, t_c = Point(20,20), Vec(0,-2), 1
# construct a new point here using coordinates corresponding to a point that results from the evaluation of the line above
pc = ???

p_origin_d, vec_d, t_d = Point(0,0,10), Vec(0,0,10), -2
# construct a new point here using coordinates corresponding to a point that results from the evaluation of the line above
pd = ???
```

## Lines and Planes in Decod.es

#### 106.02

In the space provided, author a function that converts any given vertically-oriented Decod.es Plane (that is, any plane that is perpendicular to the x-y plane) to a Decod.es CS. Instead of requiring a guide Vec, as demonstrated in the text, take advantage of the fact that the Plane is known to be vertical. Your function should successfully run so long as this condition holds.


```python
pt_rand = Point.random(Interval(-3,3))
vec_rand = Vec.random(Interval(-1,1),True)

pln_vert = Plane(pt_rand,vec_rand)

#### START YOUR WORK HERE ####
def to_cs(pln):
    ???
#### END YOUR WORK HERE ####

cs = to_cs(pln_vert)
print(cs)
```

#### 106.03

In our discussion of Planes, we present the Decod.es Circle as a special type of Plane which adds a single member, `rad` that defines the radius of the circle that lies on the underlying plane. Here we follow in this pattern in the construction of a Rectangle class as a special type of CS.

In the space provided, define a new class Rectangle as an extension of CS. Rectangle should be initialzed with arguments as shown below, and go on to add just two members to its parent: `w` as the span of the rectangle along the x-axis of the underlying CS, and `h` as the span along the y-axis.

Four properties should be defined, `pa`,`pa`,`pc`,and `pd`, that describe the corner points of the rectangle in world space. A single method should be added that returns the four Segments along the boundary of the Rectangle. This method will be called as shown below.


```python
"""
Rectangle Class
Inherits all properties of the Plane class, and also happens to require a Plane 
in its constructor
"""
class Rectangle(CS): 
    def __init__(self,cs,width,height):
        super(Rectangle,self).__init__(cs.origin, cs.x_axis, cs.y_axis)
#### START YOUR WORK HERE ####  

    ???

#### END YOUR WORK HERE ####
        
rect = Rectangle(CS(),1.5,1.5)

for seg in rect.to_segs():
    out.put(seg)
out.draw()
out.clear()
```

## Methods of Projection

#### 106.04

Since Lines are infinite, Points may be properly projected at any position along them. This does not hold true for Rays and Segments, which each offer modificaitons of the generic infinite-line projection routine as to ensure that projected Points fall within the valid ranges of the parameter $t$ for each of these finite types: $0\rightarrow\infty$ for Rays, and $0\rightarrow1$ for Segments. Here we imagine a different scenario, and this question asks for the invention a new type of LinearEntity with a different range of valid values of $t$.

In the space provided, author two functions. Each function should handle the projection of Points to a new type of LinearEntity: the ***AntiRay*** and the ***AntiSegment***. These new imaginary types hold a valid range of $t$ values that are the inverse of their more conservative cousins: $0\rightarrow-\infty$ for Rays, and the discontinious range of $-\infty\rightarrow0$ , $1\rightarrow\infty$ for Segments.


```python
"""
AntiRay Projection
"""

def near(self,proj_pt):
    line_result = self.to_line().near(proj_pt)
    ### add your work here ###
```


```python
"""
AntiSegment Projection
"""

def near(self,proj_pt):
    line_result = self.to_line().near(proj_pt)
    ### add your work here ###
```

3d4e2bc5af80b466abf0767dbc74589004d69786
ipynb
Jupyter Notebook
problem sets/Problem Set 106.ipynb
ksteinfe/decodes_ipynb
2e4bb6b398472fc61ef8b88dad7babbdeb2a5754
MIT
2018-05-15T14:31:23.000Z
2018-05-15T14:31:23.000Z
problem sets/Problem Set 106.ipynb
ksteinfe/decodes_ipynb
2e4bb6b398472fc61ef8b88dad7babbdeb2a5754
MIT
problem sets/Problem Set 106.ipynb
ksteinfe/decodes_ipynb
2e4bb6b398472fc61ef8b88dad7babbdeb2a5754
MIT
2020-05-19T05:40:18.000Z
2020-06-28T02:18:08.000Z
Qwen/Qwen-72B
1. YES
2. YES