Question
IN PYTHON WITHOUT USING PRINT Write the function lengthSegment(x1, y1, z1, x2, y2, z2) that takes 6 float values, repre- senting the Cartesian coordinates of
IN PYTHON WITHOUT USING PRINT
Write the function lengthSegment(x1, y1, z1, x2, y2, z2) that takes 6 float values, repre- senting the Cartesian coordinates of the endpoints of a line segment in 3-space, and returns the Euclidean length of this line segment. Euclidean distance in 3-space. The Euclidean distance formula that you explored in the previous problem (distOrigin) generalizes to higher dimensions elegantly: research this idea here. Foreshadowing of future Python syntax. It is rather ugly to use 6 parameters for this function: wouldnt it be better to capture a point as a single thing (so gather the three coordinates together), and then gather the 2 points as a single thing (of a different type) representing a line segment? This would allow 1 or 2 parameters rather than 6. We will later see how to gather several related values together in a sequence, container, or class. Given the structure of the Euclidean distance formula, it is also tempting to repeat the same calculation, marching down the coordinates, a foreshadowing of iteration. So this version of this computation is not the final ideal form for clarity and efficiency.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started