Permalink
Browse files

Factor out physics example. Physics is now a library.

  • Loading branch information...
1 parent 82bf8fa commit 46688b7b4cca8667d214cedc7ca072b7b8dc2422 @dharmatech committed Jan 19, 2013
@@ -0,0 +1,67 @@
+<?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>{51C1B8ED-EDB7-443F-BE76-58A881EEFB20}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>PSE_Example_4._3_The_Long_Jump</RootNamespace>
+ <AssemblyName>PSE Example 4.3 The Long-Jump</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>
+ </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,102 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Symbolism;
+using Physics;
+
+namespace PSE_Example_4._3_The_Long_Jump
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ // A long-jumper leaves the ground at an angle of 20.0° above
+ // the horizontal and at a speed of 11.0 m/s.
+ // (a) How far does he jump in the horizontal direction?
+ // (Assume his motion is equivalent to that of a particle.)
+ // (b) What is the maximum height reached?
+
+ // For the purposes of solving the problem, let's take
+ // point A as the initial position
+ // point B as the peak position
+ // point C as the final position.
+
+ // First we'll get the answer in a symbolic form.
+
+ var thA = new Symbol("thA"); // angle at point A
+ var vA = new Symbol("vA"); // velocity at point A
+
+ // var g = new DoubleFloat(9.8);
+
+ var g = new Symbol("g");
+
+ var _g = new Point(new Integer(0), -g);
+
+ // An Obj representing the object at A:
+
+ var objA =
+ new Obj()
+ {
+ position = new Point(0, 0),
+ velocity = Point.FromAngle(thA, vA),
+ acceleration = _g,
+ time = new Integer(0)
+ };
+
+ var objB =
+ new Obj()
+ {
+ position = new Point(),
+ velocity = new Point(objA.velocity.x, new Integer(0)),
+ acceleration = _g
+ };
+
+ var timeB = Calc.Time(objA, objB);
+ var timeC = timeB * 2;
+
+ objB = objA.AtTime(timeB);
+ var objC = objA.AtTime(timeC);
+
+ Console.WriteLine("How far does he dump in the horizontal direction?");
+ Console.WriteLine(objC.position.x);
+
+ Console.WriteLine();
+
+ Console.WriteLine("What is the maximum height reached?");
+ Console.WriteLine(objB.position.y);
+
+ Console.WriteLine();
+
+ Console.WriteLine("Now for the numerical solutions:");
+
+ Console.WriteLine();
+
+ Console.WriteLine("Distance jumped: ");
+
+ Console.WriteLine(
+ objC.position.x
+ .Substitute(thA, Trig.ToRadians(20))
+ .Substitute(g, new DoubleFloat(9.8))
+ .Substitute(Trig.Pi, new DoubleFloat(3.14159))
+ .Substitute(vA, new Integer(11))
+ );
+
+ Console.WriteLine();
+
+ Console.WriteLine("Maximum height reached: ");
+
+ Console.WriteLine(
+ objB.position.y
+ .Substitute(g, new DoubleFloat(9.8))
+ .Substitute(thA, Trig.ToRadians(20))
+ .Substitute(Trig.Pi, new DoubleFloat(3.14159))
+ .Substitute(vA, new Integer(11))
+ );
+
+ 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 Example 4.3 The Long-Jump")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("PSE Example 4.3 The Long-Jump")]
+[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("7f873ffc-5db9-40a5-a5f9-ee0e7e76734a")]
+
+// 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
@@ -6,7 +6,7 @@
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{73E0C26D-5333-4575-A3E9-5388E975446E}</ProjectGuid>
- <OutputType>Exe</OutputType>
+ <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Physics</RootNamespace>
<AssemblyName>Physics</AssemblyName>
@@ -33,6 +33,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
View
@@ -7,7 +7,7 @@
namespace Physics
{
- static class Trig
+ public static class Trig
{
public static Symbol Pi = new Symbol("Pi");
@@ -26,7 +26,7 @@ public static MathObject Cos(MathObject arg)
{ return new Symbolism.Cos(arg).Simplify(); }
}
- class Point
+ public class Point
{
public MathObject x;
public MathObject y;
@@ -55,7 +55,7 @@ public override string ToString()
{ return new Point(a.x / b, a.y / b); }
}
- class Obj
+ public class Obj
{
public Point position;
public Point velocity;
@@ -90,7 +90,7 @@ public Obj AtTime(MathObject t)
}
}
- static class Calc
+ public static class Calc
{
public static MathObject Time(Obj a, Obj b)
{
@@ -111,95 +111,4 @@ public static MathObject Time(Obj a, Obj b)
throw new Exception();
}
}
-
- class Program
- {
- static void Main(string[] args)
- {
- // A long-jumper leaves the ground at an angle of 20.0° above
- // the horizontal and at a speed of 11.0 m/s.
- // (a) How far does he jump in the horizontal direction?
- // (Assume his motion is equivalent to that of a particle.)
- // (b) What is the maximum height reached?
-
- // For the purposes of solving the problem, let's take
- // point A as the initial position
- // point B as the peak position
- // point C as the final position.
-
- // First we'll get the answer in a symbolic form.
-
- var thA = new Symbol("thA"); // angle at point A
- var vA = new Symbol("vA"); // velocity at point A
-
- // var g = new DoubleFloat(9.8);
-
- var g = new Symbol("g");
-
- var _g = new Point(new Integer(0), -g);
-
- // An Obj representing the object at A:
-
- var objA =
- new Obj()
- {
- position = new Point(0, 0),
- velocity = Point.FromAngle(thA, vA),
- acceleration = _g,
- time = new Integer(0)
- };
-
- var objB =
- new Obj()
- {
- position = new Point(),
- velocity = new Point(objA.velocity.x, new Integer(0)),
- acceleration = _g
- };
-
- var timeB = Calc.Time(objA, objB);
- var timeC = timeB * 2;
-
- objB = objA.AtTime(timeB);
- var objC = objA.AtTime(timeC);
-
- Console.WriteLine("How far does he dump in the horizontal direction?");
- Console.WriteLine(objC.position.x);
-
- Console.WriteLine();
-
- Console.WriteLine("What is the maximum height reached?");
- Console.WriteLine(objB.position.y);
-
- Console.WriteLine();
-
- Console.WriteLine("Now for the numerical solutions:");
-
- Console.WriteLine();
-
- Console.WriteLine("Distance jumped: ");
-
- Console.WriteLine(
- objC.position.x
- .Substitute(thA, Trig.ToRadians(20))
- .Substitute(g, new DoubleFloat(9.8))
- .Substitute(Trig.Pi, new DoubleFloat(3.14159))
- .Substitute(vA, new Integer(11))
- );
-
- Console.WriteLine();
-
- Console.WriteLine("Maximum height reached: ");
-
- Console.WriteLine(
- objB.position.y
- .Substitute(g, new DoubleFloat(9.8))
- .Substitute(thA, Trig.ToRadians(20))
- .Substitute(Trig.Pi, new DoubleFloat(3.14159))
- .Substitute(vA, new Integer(11))
- );
-
- Console.ReadLine();
- }
- }
}
View
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Physics", "Physics\Physics.csproj", "{73E0C26D-5333-4575-A3E9-5388E975446E}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PSE Example 4.3 The Long-Jump", "PSE Example 4.3 The Long-Jump\PSE Example 4.3 The Long-Jump.csproj", "{51C1B8ED-EDB7-443F-BE76-58A881EEFB20}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
@@ -25,6 +27,10 @@ Global
{73E0C26D-5333-4575-A3E9-5388E975446E}.Debug|x86.Build.0 = Debug|x86
{73E0C26D-5333-4575-A3E9-5388E975446E}.Release|x86.ActiveCfg = Release|x86
{73E0C26D-5333-4575-A3E9-5388E975446E}.Release|x86.Build.0 = Release|x86
+ {51C1B8ED-EDB7-443F-BE76-58A881EEFB20}.Debug|x86.ActiveCfg = Debug|x86
+ {51C1B8ED-EDB7-443F-BE76-58A881EEFB20}.Debug|x86.Build.0 = Debug|x86
+ {51C1B8ED-EDB7-443F-BE76-58A881EEFB20}.Release|x86.ActiveCfg = Release|x86
+ {51C1B8ED-EDB7-443F-BE76-58A881EEFB20}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

0 comments on commit 46688b7

Please sign in to comment.