Code Monkey home page Code Monkey logo

calculator_pi's Introduction

Version 1.8
===========
Testing for cross-compiling.

Version 1.7
===========
This version compiles using VS2013. Formatting using thousands is bypassed. Simple formatting of answers only.
Compiles standalone, copy opencpn.lib and maybe muparser32.lib and link these in.


Changes to version 1.6
=======================================
Added Willson Fetch Equation
Added wind speed to Beaufort equation
Changed to MuParser math interface
Added History pulldown box, improved history box behaviour
Added reporting modes (1000 separator, SI prefixes, accuracy)
Added function button in OpenCPN toolbar, with option to switch off from plugin settings
Minor tweaks and fixes

Calculator Plugin for OpenCPN by SaltyPaws aka Walbert Schulpen
=======================================

This is a light weight yet powerful calculator plugin for OpenCPN. Would you like to know your hull speed? 

Key features are:
* Storing results in variables
* Shows historic calculations
* Full complement of nautical functions
* Screen footprint can be optimised & minimised as required

Adding formulas is easy. If your favorite nautical equation is missing, please let me know your equation via flyspray, and I will add it.

Help
=========
Type help in the calculator to get these instructions.

Examples of expression that work in the calculator are: (comments are in brackets, some results depend on other example calculations):
=========
Hull speed:
	LWL=48			(water line lenght in feet)
	vhull=1.34*LWL^(1/2)	(hull speed in knots)

Conversions:
	ftm=0.3048			(feet to meters)
	km_to_nm=0.539957		(Kilometers to nautical Mile)
	ftm*LWL			(waterline length in meters)

Distance to horizon
	R=6378.1*1000		(Radius of the earth in m)
	H=2.5			(Height of the eye above sea-level in m)
	d = R * acos(R/(R + h))	(Distance to horizon in m)   
	ans*km_to_nm		(Distance to horizon in nm)

Distance to lighthouse
	H1=200			(height of lighthouse in m)
	d1 = R*acos(R/(R + H1))	(Distance to horizon in m)
	distance=d1+d		(visibility range of lighthouse in m)

Built-in functions

The following table gives an overview of the functions supported by the default implementation. It lists the function names, the number of arguments and a brief description.
Name 	Argc. 	Explanation
sin 	1 	sine function
cos 	1 	cosine function
tan 	1 	tangens function
asin 	1 	arcus sine function
acos 	1 	arcus cosine function
atan 	1 	arcus tangens function
sinh 	1 	hyperbolic sine function
cosh 	1 	hyperbolic cosine
tanh 	1 	hyperbolic tangens function
asinh 	1 	hyperbolic arcus sine function
acosh 	1 	hyperbolic arcus tangens function
atanh 	1 	hyperbolic arcur tangens function
log2 	1 	logarithm to the base 2
log10 	1 	logarithm to the base 10
log 	1 	logarithm to the base 10
ln 	1 	logarithm to base e (2.71828...)
exp 	1 	e raised to the power of x
sqrt 	1 	square root of a value
sign 	1 	sign function -1 if x<0; 1 if x>0
rint 	1 	round to nearest integer
abs 	1 	absolute value
min 	var. 	min of all arguments
max 	var. 	max of all arguments
sum 	var. 	sum of all arguments
avg 	var. 	mean value of all arguments


Built-in binary operators

The following table lists the default binary operators supported by the parser.
Operator 	Meaning 	Priority
= 		assignement 			-1
&& 		logical and 			1
|| 		logical or 			2
<= 		less or equal 			4
>= 		greater or equal 		4
!= 		not equal 			4
== 		equal 				4
> 		greater than 			4
< 		less than 			4
+ 		addition 			5
- 		subtraction 			5
* 		multiplication 			6
/ 		division 			6
^ 		raise x to the power of y 	7
*The assignment operator is special since it changes one of its arguments and can only by applied to variables.
Other operators

muParser has built in support for the if then else operator. It uses lazy evaluation in order to make sure only the necessary branch of the expression is evaluated.
Operator 	Meaning 	Remarks
?: 	if then else operator 	C++ style syntax
 
Variables:
	pi, e
	ans is the result of the previous calulation
	dtr is the conversion factor from degrees to radians		
	you can define your own variables (e.g. myvariable=10/8*cos(dtr*90) or yourvariable=ans)
	clear removes results in the history, but leaves your defined variables in tact

User Interface - type these commands in the command window:
	history - Toggle the history panel
	showhelp - Show/Hide the Help button
	showcalculate - Show/Hide the Calculate button
	showhistory - Show/Hide the history toggle
	help - show the help menu

Settings/Plugins/Preferences:
	Show/Hide Calculate, Help and History toggle buttons
	History Settings: max Results -this is the number of results that will be stored in the history pulldown. The history pulldown will contain five times this value
	Log to opencpn: Enable/Disable logging of results to opencpn logfile.
 
Other:
	Error handling supported
	MuParser has been compiled with C++ Double for internal precision.

Compiling
=========
You have to be able to compile OpenCPN itself - Get the info at http://opencpn.org/ocpn/developers_manual

* git clone https://github.com/SaltyPaws/Calc_pi_muparser.git

Build out of OpenCPN branch!

in folder calculator_pi

* mkdir build
* cd build
* cmake ..
* make
* sudo make installf

After using wxformbuilder to modify the interface, use degreefix.sh, to facillitate the windows build.
When updating the Excel file with formulas and conversions, convert to cpp code by running the supplied perl script

Executables
=========
Compiled library files can be downloaded/uploaded here.
https://sourceforge.net/projects/opencpnplugins/

License
=======
The plugin is licensed under the terms of GPL v2 or, at your will, later. 
The MuParser files are by Ingo Berg and is open source. For full licence, please see the muparser source files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.