Distance between two points:
d = sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2)
****************************************************(DRAFT - this document is not complete yet)****************************************************
App Inventor has a complete set of Math blocks available.Along with local and global variables and lists, for doing anything from basic expressions to complex formulas.There are the basic arithmetic blocks for addition, subtraction, multiplication and division.There are 'algebra' blocks such as sqrt, abs, log, and ^ (powers)There are trigonometric functions like sin, cos, and tan and their inverses.Pretty much everything you need.This tutorial will focus on the methods that I use to write math expressions in App Inventor.---In order to understand how to construct a math expression you should first know 'order of operations':This will be especially important when converting from a written text formula to App Inventor blocks.Order of Operations:Do what is inside parentheses first. (P)Evaluate exponents. (E)Multiply or divide before adding and subtracting. (MDAS)Work left-to-right.An acronym to remember this is 'PEMDAS'
Examples:
4 + 6 - 2 = (4 + 6) - 2 = 10 - 2 = 8 ; Left-to-right since operators have the same precedence
4 * 6 - 2 = (4 * 6) - 2 = 24 - 2 = 22 ; MD before AS
4 + 6 * 2 = 4 + (6 * 2) = 4 + 12 = 16 ; MD before AS
We can override order of operations with parentheses:
4 * (6 + 2) = 4 * 8 = 32 ; P before M
(Since I cannot write superscripts It can be assumed that the expression that follows a caret '^' is the exponent in the following examples:)
--2^3 + 1 = 8 + 1 = 9 ; E before AS
(you have received this message from the App Inventor Developers Library)
---
You received this message because you are subscribed to the Google Groups "App Inventor Developers Library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to app-inventor-develope...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.