Qurak

Billiard balls

ఉదాహరణ 5 దశలు, ఒకే సెషన్‌లో క్రమంగా నడుస్తాయి. ప్రతి దశా ఇంజిన్‌పై అమలు చేయబడింది, కింది అవుట్‌పుట్ అది ఇచ్చినదే.

దశ 1
{sol1, sol2} = Map[NDSolve[{x'[t] == a[t], y'[t] == b[t], x[0] == 0, y[0] == 0, a[0] == 1, b[0] == #, WhenEvent[x[t] ^ 2 == 1, a[t] -> -a[t]], WhenEvent[y[t] ^ 2 == 1, b[t] -> -b[t]]}, {x, y}, {t, 0, 100}, DiscreteVariables -> {a, b}]&, {Rationalize[Sqrt[2], .01], Sqrt[2]}];

అవుట్‌పుట్ లేదు - ఈ దశ తదుపరి దానికి ఏదో సిద్ధం చేస్తుంది.

దశ 2
GraphicsGrid[{Map[ParametricPlot[{x[t], y[t]} /. sol1, {t, 0, #}, Frame -> True, FrameTicks -> None, PlotRange -> 1, Axes -> False, PlotStyle -> Blue]&, {5, 20, 100}],
	Map[ParametricPlot[{x[t], y[t]} /. sol2, {t, 0, #}, Frame -> True, FrameTicks -> None, PlotRange -> 1, Axes -> False, PlotStyle -> Red]&, {5, 20, 100}]}, ImageSize -> Large]
అవుట్‌పుట్
-Graphics-
దశ 3
ball3d[r1_ ? NumericQ, r2_ ? NumericQ] := NDSolve[{x'[t] == a[t], y'[t] == b[t], z'[t] == c[t], x[0] == 0, y[0] == 0, z[0] == 0, a[0] == 1, b[0] == r1, c[0] == r2, WhenEvent[x[t] ^ 2 - 1, a[t] -> -a[t]], WhenEvent[y[t] ^ 2 - 1, b[t] -> -b[t]], WhenEvent[z[t] ^ 2 - 1, c[t] -> -c[t]]}, {x[t], y[t], z[t]}, {t, 0, 200}, DiscreteVariables -> {a, b, c}];

అవుట్‌పుట్ లేదు - ఈ దశ తదుపరి దానికి ఏదో సిద్ధం చేస్తుంది.

దశ 4
{sol3d1, sol3d2} = {ball3d[1 / 3, 2 / 3], ball3d[Sqrt[2], Sqrt[3]]};

అవుట్‌పుట్ లేదు - ఈ దశ తదుపరి దానికి ఏదో సిద్ధం చేస్తుంది.

దశ 5
GraphicsGrid[{Map[ParametricPlot3D[{x[t], y[t], z[t]} /. sol3d1, {t, 0, #}, Axes -> False, PlotStyle -> Blue]&, {5, 20, 100}],
	Map[ParametricPlot3D[{x[t], y[t], z[t]} /. sol3d2, {t, 0, #}, Axes -> False, PlotStyle -> Red]&, {1, 50, 200}]}, ImageSize -> Large]
అవుట్‌పుట్
-Graphics-

వాడిన ఫంక్షన్లు

సంబంధిత రెసిపీలు

అన్ని రెసిపీలు · ఫంక్షన్ రిఫరెన్స్ · దీన్ని MCP క్లయింట్ నుండి వాడండి