Wolfram Book 之直线方程、两直线的位置关系

例 1

可见,直线 AB,BC,CA 的斜率分别是 1/7,-1/2,1.

Mathematica 代码:

With[{A = {3, 2}, B = {-4, 1}, C = {0, -1}},

With[{lines =

InterpolatingPolynomial[#, x] & /@ {{A, B}, {B, C}, {C, A}} //

Expand},

Plot[lines, {x, -12, 8}, PlotLegends -> lines,

Epilog -> {Point@{A, B, C}, Text[“A”, A + {0.1, 0.5}],

Text[“B”, B + {-0.3, -0.5}], Text[“C”, C + {0.7, 0}]},

AspectRatio -> Automatic, GridLines -> {Range[-15, 15]}]

]

]

例 2

编制程序,计算直线 BA,PQ 的斜率,并画出图形,判断关系

可见直线 AB 和 PQ 平行.

Mathematica 代码:

With[{A = {2, 3}, B = {-4, 0}, P = {-3, 1}, Q = {-1, 2}},

With[{lines =

InterpolatingPolynomial[#, x] & /@ {{A, B}, {P, Q}} // Expand},

Plot[lines, {x, -6, 6}, PlotLegends -> lines,

Epilog ->{Point /@ {{A, B}, {P, Q}}}, AspectRatio -> Automatic,

GridLines -> {Range[-9, 9]}]

]

]

例 3

结合计算和绘图,可以发现直线 AB 和 CD 的斜率一样,AB∥CD,直线 BC 和直线 AD 的斜率一样,BC∥AD,所以四边形 ABCD 是平行四边形,另外 AB 的斜率与 BC 的斜率之积等于-1,所以 AB⊥BC,所以四边形 ABCD 是矩形.

Mathematica 代码

With[{A = {2, 2 + 2 Sqrt[2]}, B = {-2, 2}, C = {0, 2 – 2 Sqrt[2]},

D = {4, 2}},

With[{lines =

InterpolatingPolynomial[#, x]& /@ {{A, B}, {B, C}, {C, D}, {D,

A}} // Expand},

Plot[lines, {x, -9, 9}, PlotRange -> 9, PlotLegends -> lines,

Epilog -> {Point@{A, B, C}, Text[“A”, A + {0.1, 0.5}],

Text[“B”, B + {-0.3, -0.5}], Text[“C”, C + {0.7, 0}],

Text[“D”, D + {0.7, 0}]}, AspectRatio -> Automatic,

GridLines -> {Range[-9, 9]}]

]

]

 

发布者:Cara,转载请注明出处:http://www.makercollider.com/course/2206

发表评论

登录后才能评论
QR code