{
"cells": [
{
"cell_type": "markdown",
"source": [
"# Vector Product Examples\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"from numpy import *"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## Dot Product Example\n",
"\n",
"A bead at $C$ can move along the straight rod $AB$. An elastic cord $CD$ is under tension and is attached to the bead. The distance from $B$ to $C$ is 11 cm.\n",
"\n",
"Due to the cord force only, will be tend to slide toward A or B?\n",
"\n",
"![](images/dot-example.png)\n",
"\n",
"We want to find the dot product $\\vec{r}_{CB} \\cdot \\vec{r}_{CD}$. If this is\n",
"positive, then the angle $BCD < 90^\\circ$, and bead will be pulled up the bar\n",
"toward $B$. If the dot product is negative, the bead will be pulled toward $A$.\n",
"\n",
"To get the vectors $\\vec{r}_{CB}$ and $\\vec{r}_{CD}$, start with the vectors we\n",
"do know: $\\vec{r}_{AB}$ and $\\vec{r}_{BD}$.\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"rAB = array(( -18, 4, -16+4 )) # cm\n",
"rBD = array(( 15, 17-4, -4 )) # cm"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Vector $\\vec{r}_{CB}$ must have a magnitude of 11cm, and points in the\n",
"direction of the unit vector $\\hat{u}_{AB}$.\n",
" \n",
"Find the unit vector $\\hat{u}_{AB}$ and use it to define $\\vec{r}_{CB}$.\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"rABmag = sqrt(sum(rAB**2))\n",
"uAB = rAB / rABmag\n",
"rCB = 11*uAB\n",
"\n",
"rCD = rBD + rCB"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"Compute the dot product $\\vec{r}_{AB} \\cdot \\vec{r}_{CD}$.\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"dot(rAB,rCD)"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"The positive dot product tells us $\\vec{r}_{AB}$ and $\\vec{r}_{CD}$ are more\n",
"parallel than they are anti-parallel. That is, the angle between these vectors\n",
"is less than $90^{\\circ}$. We don't really care what the magnitude of the dot\n",
"product is. This means the bead will slide in the $\\vec{r}_{AB}$ direction,\n",
"toward $B$.\n",
"\n",
"---------------------------------\n",
"\n",
"## Cross Product Example\n",
"\n",
"A contractor is required to prepare a surface so that it is nearly perfectly\n",
"horizontal. The contract specifies that the normal to the surface must be\n",
"within 0.5\u00b0. \n",
"\n",
"The elevation of points $A$ and $B$, relative to the elevation at point $C$ are\n",
"-3.3 ft and -4.3 ft, respectively. Determine the angle between the surface's\n",
"normal direction and the vertical. Is it sufficiently level?\n",
"\n",
"![](images/cross-product-example.png)\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"rCA = array(( 410., 0., -3.3 )) # ft\n",
"rCB = array(( 0., 507., -4.3 )) # ft"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"rN = cross(rCA,rCB) # vector normal to surface (upward)\n",
"uN = rN / sqrt(sum(rN**2)) # unit normal\n",
"print ('normal vector is',uN)"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"We need to find the angle between this unit normal vector ($\\hat{n}$) and\n",
"$\\hat{k}$. We'll use a dot product for that: \n",
"\n",
"$$\\hat{n} \\cdot \\hat{k} = \\cos \\theta$$\n",
"\n",
"$$\\theta = \\cos^{-1} \\left (\\hat{n} \\cdot \\hat{k} \\right )$$\n"
],
"metadata": {}
},
{
"cell_type": "code",
"source": [
"dtr = pi/180 # factor for degree-to-radian conversion\n",
"khat = array((0,0,1))\n",
"angle = arccos( dot(uN,khat) )\n",
"print ('angle of normal from vertical is ', angle/dtr, 'degrees')"
],
"metadata": {},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"### Solution:\n",
"\n",
"The angle is $0.67^\\circ$. The surface is *not* sufficiently level.\n"
],
"metadata": {}
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}