Skip to content

Commit

Permalink
PSE 5E Problem 5.15
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmatech committed Mar 27, 2013
1 parent fc1ff21 commit 568c61d
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 11 deletions.
@@ -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>{87EAEC17-957D-4137-9F7B-6960EE59EEA5}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PSE_5E_Problem_5._15_Two_Forces_One_Mass</RootNamespace>
<AssemblyName>PSE 5E Problem 5.15 Two Forces One Mass</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>
98 changes: 98 additions & 0 deletions PSE 5E Problem 5.15 Two Forces One Mass/Program.cs
@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Symbolism;
using Physics;
using Utils;

namespace PSE_5E_Problem_5._15_Two_Forces_One_Mass
{
class Program
{
static void Main(string[] args)
{
// Two forces _F1 and _F2 act on a 5.00-kg mass.
// If F1 = 20.0 N and F2 = 15.0 N, find the accelerations in
// (a) and (b) of Figure P5.15.

var F1 = new Symbol("F1");
var F2 = new Symbol("F2");

var th1 = new Symbol("th1");
var th2 = new Symbol("th2");

var m = new Symbol("m");

var obj = new Obj() { mass = m };

obj.forces.Add(Point.FromAngle(th1, F1));
obj.forces.Add(Point.FromAngle(th2, F2));

"symbolic:".Disp(); "".Disp();

"acceleration.x:".Disp(); "".Disp();

obj.Acceleration().x.Disp(); "".Disp();

"acceleration.y:".Disp(); "".Disp();

obj.Acceleration().y.Disp(); "".Disp();

"numeric (th2 = 90 deg):".Disp(); "".Disp();

Console.Write("acceleration is ");

Console.Write(
obj.Acceleration().Norm()
.Substitute(th1, 0.0)
.Substitute(F1, 20)
.Substitute(th2, (90).ToRadians())
.Substitute(F2, 15)
.Substitute(m, 5)
.Substitute(Trig.Pi, Math.PI));

Console.Write(" at ");

Console.Write(
obj.Acceleration().ToAngle().ToDegrees()
.Substitute(th1, 0.0)
.Substitute(F1, 20)
.Substitute(th2, (90).ToRadians())
.Substitute(F2, 15)
.Substitute(m, 5)
.Substitute(Trig.Pi, Math.PI));

Console.Write(" degrees"); "".Disp(); "".Disp();

"numeric (th2 = 60 deg):".Disp(); "".Disp();

Console.Write("acceleration is ");

Console.Write(
obj.Acceleration().Norm()
.Substitute(th1, 0.0)
.Substitute(F1, 20)
.Substitute(th2, (60).ToRadians())
.Substitute(F2, 15)
.Substitute(m, 5)
.Substitute(Trig.Pi, Math.PI));

Console.Write(" at ");

Console.Write(
obj.Acceleration().ToAngle().ToDegrees()
.Substitute(th1, 0.0)
.Substitute(F1, 20)
.Substitute(th2, (60).ToRadians())
.Substitute(F2, 15)
.Substitute(m, 5)
.Substitute(Trig.Pi, Math.PI));

Console.Write(" degrees"); Console.WriteLine();

Console.ReadLine();
}
}
}
36 changes: 36 additions & 0 deletions PSE 5E Problem 5.15 Two Forces One Mass/Properties/AssemblyInfo.cs
@@ -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 5.15 Two Forces One Mass")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PSE 5E Problem 5.15 Two Forces One Mass")]
[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("ee0a9cc1-52ff-4606-b7e4-71f44c038644")]

// 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")]
46 changes: 35 additions & 11 deletions Physics/Physics.cs
Expand Up @@ -67,6 +67,9 @@ public class Point
public MathObject x;
public MathObject y;

public MathObject angle;
public MathObject magnitude;

public Point() { }

public Point(MathObject x_val, MathObject y_val)
Expand Down Expand Up @@ -115,6 +118,12 @@ public MathObject Norm()
public MathObject ToAngle() { return Trig.Atan2(y, x); }
}

//public class Polar
//{
// public MathObject angle;
// public MathObject magnitude;
//}

public class Obj
{
public MathObject mass;
Expand All @@ -130,11 +139,11 @@ public class Obj

// public Point[] forces;

public List<Point> forces;
public List<Point> forces = new List<Point>();

public MathObject[] forceMagnitudes;
// public List<MathObject> forceMagnitudes;

public MathObject[] forceAngles;
// public List<MathObject> forceAngles;

public Point totalForce;

Expand Down Expand Up @@ -251,16 +260,28 @@ public Point ProjectileInclineIntersection(MathObject theta)

public MathObject TotalForceX()
{
MathObject Fx = 0;
if (forces.All(force => force.angle != null)
&&
forces.All(force => force.magnitude != null))
{

forces.ForEach(elt =>
{
if (elt.x == null)
throw new Exception();
Fx += elt.x;
});
}

return Fx;
if (forces.All(force => force.x != null))
{
MathObject Fx = 0;

forces.ForEach(elt =>
{
if (elt.x == null)
throw new Exception();
Fx += elt.x;
});

return Fx;
}

throw new Exception();
}

public MathObject TotalForceY()
Expand Down Expand Up @@ -294,6 +315,9 @@ public MathObject AccelerationY()
throw new Exception();
}

public Point Acceleration()
{ return new Point(AccelerationX(), AccelerationY()); }

public Point VelocityAtTime(MathObject t)
{
var dt = t - time;
Expand Down
12 changes: 12 additions & 0 deletions Symbolism.sln
Expand Up @@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PSE 5E Problem 4.17 Cannon
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PSE 5E PROBLEM 5.20 Three Forces Find Acceleration and Mass", "PSE 5E PROBLEM 5.20 Three Forces Find Acceleration and Mass\PSE 5E PROBLEM 5.20 Three Forces Find Acceleration and Mass.csproj", "{F07ABCCA-AADC-4562-8E83-A17746EC75B6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PSE 5E Problem 5.15 Two Forces One Mass", "PSE 5E Problem 5.15 Two Forces One Mass\PSE 5E Problem 5.15 Two Forces One Mass.csproj", "{87EAEC17-957D-4137-9F7B-6960EE59EEA5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -155,6 +157,16 @@ Global
{F07ABCCA-AADC-4562-8E83-A17746EC75B6}.Release|Mixed Platforms.Build.0 = Release|x86
{F07ABCCA-AADC-4562-8E83-A17746EC75B6}.Release|x86.ActiveCfg = Release|x86
{F07ABCCA-AADC-4562-8E83-A17746EC75B6}.Release|x86.Build.0 = Release|x86
{87EAEC17-957D-4137-9F7B-6960EE59EEA5}.Debug|Any CPU.ActiveCfg = Debug|x86
{87EAEC17-957D-4137-9F7B-6960EE59EEA5}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{87EAEC17-957D-4137-9F7B-6960EE59EEA5}.Debug|Mixed Platforms.Build.0 = Debug|x86
{87EAEC17-957D-4137-9F7B-6960EE59EEA5}.Debug|x86.ActiveCfg = Debug|x86
{87EAEC17-957D-4137-9F7B-6960EE59EEA5}.Debug|x86.Build.0 = Debug|x86
{87EAEC17-957D-4137-9F7B-6960EE59EEA5}.Release|Any CPU.ActiveCfg = Release|x86
{87EAEC17-957D-4137-9F7B-6960EE59EEA5}.Release|Mixed Platforms.ActiveCfg = Release|x86
{87EAEC17-957D-4137-9F7B-6960EE59EEA5}.Release|Mixed Platforms.Build.0 = Release|x86
{87EAEC17-957D-4137-9F7B-6960EE59EEA5}.Release|x86.ActiveCfg = Release|x86
{87EAEC17-957D-4137-9F7B-6960EE59EEA5}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 568c61d

Please sign in to comment.