Permalink
Browse files

PSE 5E PROBLEM 4.9

  • Loading branch information...
1 parent 63d0d8d commit 8fc20eabae54d857a9a7cdeba304f0ebb8b3325c @dharmatech committed Mar 11, 2013
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{E867D14B-BCE4-4EF6-93D0-8E3102566E49}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>PSE_5E_Problem_4._9_Projectile_Motion</RootNamespace>
+ <AssemblyName>PSE 5E Problem 4.9 Projectile Motion</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Physics\Physics.csproj">
+ <Project>{73E0C26D-5333-4575-A3E9-5388E975446E}</Project>
+ <Name>Physics</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Symbolism\Symbolism.csproj">
+ <Project>{067278C5-2A0F-42DE-838B-855EFB652608}</Project>
+ <Name>Symbolism</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Utils\Utils.csproj">
+ <Project>{A3F0F5DB-7EB2-488F-B79C-F667C4E5AB02}</Project>
+ <Name>Utils</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Symbolism;
+using Physics;
+using Utils;
+
+namespace PSE_5E_Problem_4._9_Projectile_Motion
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ // In a local bar, a customer slides an empty beer mug
+ // down the counter for a refill. The bartender is
+ // momentarily distracted and does not see the mug, which slides
+ // off the counter and strikes the floor 1.40 m from the
+ // base of the counter. If the height of the counter is
+ // 0.860 m, (a) with what velocity did the mug leave the
+ // counter and (b) what was the direction of the mug’s
+ // velocity just before it hit the floor?
+
+ var xA = new Symbol("xA"); // position.x at point A
+ var yA = new Symbol("yA"); // position.y at point A
+ var thA = new Symbol("thA"); // angle at point A
+ var vA = new Symbol("vA"); // velocity at point A
+
+ var xB = new Symbol("xB");
+
+ var g = new Symbol("g"); // magnitude of gravity
+ var _g = new Point(0, -g); // gravity vector
+
+ Func<MathObject, MathObject> numeric = obj =>
+ obj
+ .Substitute(xA, 0)
+ .Substitute(xB, 1.4)
+ .Substitute(yA, 0.86)
+ .Substitute(g, 9.8)
+ .Substitute(Trig.Pi, 3.14159);
+
+ var objA = new Obj()
+ {
+ position = new Point(xA, yA),
+ velocity = new Point(null, 0),
+ acceleration = _g,
+ time = 0
+ };
+
+ var objB = new Obj()
+ {
+ position = new Point(xB, 0),
+ velocity = new Point(null, null),
+ acceleration = _g
+ };
+
+ var timeB = Calc.Time(objA, objB, 1);
+
+ objB.time = timeB;
+
+ var _vA = Calc.InitialVelocity(objA, objB);
+
+ objA.velocity = _vA;
+
+ "With what velocity did the mug leave the counter?".Disp(); "".Disp();
+
+ "symbolic:".Disp();
+
+ "x:".Disp(); _vA.x.Disp();
+
+ "y:".Disp(); _vA.y.Disp();
+
+ "".Disp();
+
+ "numeric:".Disp();
+
+ "x:".Disp(); numeric(_vA.x).Disp();
+
+ "y:".Disp(); numeric(_vA.y).Disp();
+
+ "".Disp();
+
+ "What was the direction of the mug’s velocity just before it hit the floor?".Disp(); "".Disp();
+
+ objB = objA.AtTime(timeB);
+
+ "symbolic:".Disp();
+
+ objB.velocity.ToAngle().Disp(); "".Disp();
+
+ "numeric:".Disp();
+
+ numeric(objB.velocity.ToAngle().ToDegrees()).Disp();
+
+ Console.ReadLine();
+ }
+ }
+}
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("PSE 5E Problem 4.9 Projectile Motion")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("PSE 5E Problem 4.9 Projectile Motion")]
+[assembly: AssemblyCopyright("Copyright © 2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("38c64c74-949e-4dfd-9079-c3825afa561c")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
@@ -26,6 +26,9 @@ public static MathObject QuadraticEquation(MathObject a, MathObject b, MathObjec
throw new Exception();
}
+
+ public static bool NotNull(params MathObject[] objs)
+ { return Array.TrueForAll(objs, elt => elt != null); }
}
public static class Trig
@@ -45,6 +48,9 @@ public static MathObject Sin(MathObject arg)
public static MathObject Cos(MathObject arg)
{ return new Cos(arg).Simplify(); }
+
+ public static MathObject Atan2(MathObject a, MathObject b)
+ { return new Atan2(a, b).Simplify(); }
}
public class Point
@@ -78,14 +84,26 @@ public override string ToString()
public static Point operator +(Point a, Point b)
{ return new Point(a.x + b.x, a.y + b.y); }
+ public static Point operator -(Point a, Point b)
+ { return new Point(a.x - b.x, a.y - b.y); }
+
public static Point operator *(Point a, MathObject b)
{ return new Point(a.x * b, a.y * b); }
+ public static Point operator *(MathObject a, Point b)
+ { return b * a; }
+
public static Point operator /(Point a, MathObject b)
{ return new Point(a.x / b, a.y / b); }
+ public static Point operator /(MathObject a, Point b)
+ { return new Point(a / b.x, a / b.y); }
+
+
public MathObject Norm()
{ return (x * x + y * y) ^ (new Integer(1) / 2); }
+
+ public MathObject ToAngle() { return Trig.Atan2(y, x); }
}
public class Obj
@@ -247,5 +265,31 @@ public static MathObject Time(Obj a, Obj b, int solution = 0)
throw new Exception();
}
+
+ public static Point InitialVelocity(Obj a, Obj b)
+ {
+ if (a.time != null && b.time != null)
+ {
+ var dt = b.time - a.time;
+
+ if (Misc.NotNull(
+ a.position.x,
+ a.position.y,
+ b.position.x,
+ b.position.y,
+ a.acceleration.x,
+ a.acceleration.y))
+ {
+ var half = new Integer(1) / 2;
+
+ return
+ (b.position - a.position - half * a.acceleration * (dt ^ 2))
+ /
+ dt;
+ }
+ }
+
+ throw new Exception();
+ }
}
}
View
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PSE 5E Example 4.7 The End
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PSE 5E Example 4.6 The Stranded Explorers", "PSE 5E Example 4.6 The Stranded Explorers\PSE 5E Example 4.6 The Stranded Explorers.csproj", "{AA74302C-A679-4FDB-A988-8860EF0C4832}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PSE 5E Problem 4.9 Projectile Motion", "PSE 5E Problem 4.9 Projectile Motion\PSE 5E Problem 4.9 Projectile Motion.csproj", "{E867D14B-BCE4-4EF6-93D0-8E3102566E49}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -107,6 +109,16 @@ Global
{AA74302C-A679-4FDB-A988-8860EF0C4832}.Release|Mixed Platforms.Build.0 = Release|x86
{AA74302C-A679-4FDB-A988-8860EF0C4832}.Release|x86.ActiveCfg = Release|x86
{AA74302C-A679-4FDB-A988-8860EF0C4832}.Release|x86.Build.0 = Release|x86
+ {E867D14B-BCE4-4EF6-93D0-8E3102566E49}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {E867D14B-BCE4-4EF6-93D0-8E3102566E49}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {E867D14B-BCE4-4EF6-93D0-8E3102566E49}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {E867D14B-BCE4-4EF6-93D0-8E3102566E49}.Debug|x86.ActiveCfg = Debug|x86
+ {E867D14B-BCE4-4EF6-93D0-8E3102566E49}.Debug|x86.Build.0 = Debug|x86
+ {E867D14B-BCE4-4EF6-93D0-8E3102566E49}.Release|Any CPU.ActiveCfg = Release|x86
+ {E867D14B-BCE4-4EF6-93D0-8E3102566E49}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {E867D14B-BCE4-4EF6-93D0-8E3102566E49}.Release|Mixed Platforms.Build.0 = Release|x86
+ {E867D14B-BCE4-4EF6-93D0-8E3102566E49}.Release|x86.ActiveCfg = Release|x86
+ {E867D14B-BCE4-4EF6-93D0-8E3102566E49}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

0 comments on commit 8fc20ea

Please sign in to comment.