mirror of
https://github.com/snowykami/mbcp.git
synced 2025-08-02 19:49:58 +00:00
🐛 fix line.cal_intersection
This commit is contained in:
@ -7,7 +7,7 @@ from mbcp.mp_math.line import Line3
|
||||
from mbcp.mp_math.plane import Plane3
|
||||
from mbcp.mp_math.point import Point3
|
||||
from mbcp.mp_math.vector import Vector3
|
||||
from .answer import output_answer
|
||||
from .answer import output_ans, output_step_ans
|
||||
|
||||
|
||||
class TestWordProblem:
|
||||
@ -27,7 +27,7 @@ class TestWordProblem:
|
||||
s = pl1.normal.cross(pl2.normal)
|
||||
actual_ans = Line3(p, s)
|
||||
|
||||
output_answer(correct_ans, actual_ans, question)
|
||||
output_ans(correct_ans, actual_ans, question=question)
|
||||
assert actual_ans == correct_ans
|
||||
|
||||
"""解法2"""
|
||||
@ -38,7 +38,7 @@ class TestWordProblem:
|
||||
# 求pl3和pl4的交线
|
||||
actual_ans = pl3.cal_intersection_line3(pl4)
|
||||
|
||||
output_answer(correct_ans, actual_ans, question)
|
||||
output_ans(correct_ans, actual_ans, question=question)
|
||||
assert actual_ans == correct_ans
|
||||
|
||||
def test_c8s4e5(self):
|
||||
@ -56,21 +56,37 @@ class TestWordProblem:
|
||||
|
||||
"""解"""
|
||||
actual_ans = plane & line
|
||||
output_answer(correct_ans, actual_ans, question)
|
||||
output_ans(correct_ans, actual_ans, question=question)
|
||||
|
||||
def test_c8s4e6(self):
|
||||
question = "求过点(2, 3, 1)且与直线(x+1)/3 = (y-1)/2 = z/-1垂直相交的直线的方程。"
|
||||
"""正确答案"""
|
||||
correct_ans = Line3(Point3(2, 1, 3), Vector3(2, -1, 4))
|
||||
"""题目已知量"""
|
||||
point = Point3(2, 3, 1)
|
||||
point = Point3(2, 1, 3)
|
||||
line = Line3(Point3(-1, 1, 0), Vector3(3, 2, -1))
|
||||
|
||||
"""解"""
|
||||
# 先作平面过点且垂直与已知直线
|
||||
pl = line.cal_perpendicular(point)
|
||||
logger.debug(line.get_point(1))
|
||||
# 先作过点且垂直与已知直线的平面
|
||||
s1_correct_ans = Plane3(3, 2, -1, -5)
|
||||
pl = Plane3.from_point_and_normal(point, line.direction)
|
||||
|
||||
# output_answer(correct_ans, actual_ans, question)
|
||||
output_step_ans(s1_correct_ans, pl, question="作过点且垂直与已知直线的平面")
|
||||
|
||||
# 求该平面与已知直线的交点
|
||||
s2_correct_ans = Point3(2 / 7, 13 / 7, -3 / 7)
|
||||
s2_actual_ans = pl & line
|
||||
|
||||
output_step_ans(s2_correct_ans, s2_actual_ans, s1_correct_ans.approx(s1_correct_ans), question="求该平面与已知直线的交点")
|
||||
|
||||
# 求所求直线的方向向量
|
||||
s3_correct_ans = (-6 / 7) * Vector3(2, -1, 4)
|
||||
|
||||
dv = s2_correct_ans - point
|
||||
|
||||
output_step_ans(s3_correct_ans, dv, condition=s3_correct_ans.unit.approx(dv.unit), question="求所求直线的方向向量")
|
||||
|
||||
# 求所求直线的方程
|
||||
actual_ans = Line3(point, dv)
|
||||
|
||||
output_ans(correct_ans, actual_ans, correct_ans.approx(actual_ans), question=question)
|
||||
|
Reference in New Issue
Block a user