Tutorial by Examples

If you are working with vectors or lines you will at some stage want to get the direction of a vector, or line. Or the direction from a point to another point. Math.atan(yComponent, xComponent) return the angle in radius within the range of -Math.PI to Math.PI (-180 to 180 deg) Direction of a vect...
If you have a vector in polar form (direction & distance) you will want to convert it to a cartesian vector with a x and y component. For referance the screen coordinate system has directions as 0 deg points from left to right, 90 (PI/2) point down the screen, and so on in a clock wise direction...
To find the distance between two points we use pythagoras to get the square root of the sum of the square of the component of the vector between them. var v1 = {x : 10, y :5}; var v2 = {x : 20, y : 10}; var x = v2.x - v1.x; var y = v2.y - v1.y; var distance = Math.sqrt(x * x + y * y); // 11.180...
Math.sin and Math.cos are cyclic with a period of 2*PI radians (360 deg) they output a wave with an amplitude of 2 in the range -1 to 1. Graph of sine and cosine function: (courtesy Wikipedia) They are both very handy for many types of periodic calculations, from creating sound waves, to animati...
In XAML: <RadioButton IsChecked="{Binding EntityValue, Mode=TwoWay, Converter={StaticResource StringToIsCheckedConverter}, ConverterParameter=Male}" Content="Male"/> <RadioButton IsChecked="{Bindi...
public Result sayHello() { JsonNode json = request().body().asJson(); if(json == null) { return badRequest("Expecting Json data"); } else { String name = json.findPath("name").textValue(); if(name == null) { return badRequest...
@BodyParser.Of(BodyParser.Json.class) public Result sayHello() { JsonNode json = request().body().asJson(); String name = json.findPath("name").textValue(); if(name == null) { return badRequest("Missing parameter [name]"); } else { return ok...
A string can be used as a separator to join a list of strings together into a single string using the join() method. For example you can create a string where each element in a list is separated by a space. >>> " ".join(["once","upon","a","tim...
Python's string module provides constants for string related operations. To use them, import the string module: >>> import string string.ascii_letters: Concatenation of ascii_lowercase and ascii_uppercase: >>> string.ascii_letters 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ...
<!-- <moduleDir>/etc/<area>/di.xml --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <!-- ... --> <type name="Vendor\Namespace\Model\So...
<!-- <moduleDir>/etc/<area>/di.xml --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <!-- ... --> <preference for="Vendor\Name...
For some special cases we need to change the behavior of the Regular Expression, this is done using flags. Flags can be set in two ways, through the flags keyword or directly in the expression. Flags keyword Below an example for re.search but it works for most functions in the re module. m = re.s...
This is a script saved as .Rmd, on the contrary of r scripts saved as .R. To knit the script, either use the render function or use the shortcut button in Rstudio. --- title: "Rstudio exemple of a rmd file" author: 'stack user' date: "22 July 2016" output: html_document -...
CommandDescriptionCtrl+EScroll one line down.Ctrl+DScroll half a screen down (configurable using the scroll option).Ctrl+FScroll a full screen down.z+Draw the first line below the window at the top of the window.
CommandDescriptionCtrl+YScroll one line up.Ctrl+UScroll half a screen up (configurable using the scroll option).Ctrl+BScroll a full screen up.z^Draw the first line above the window at the bottom of the window.
CommandDescriptionzRedraw current line at the top of the window and put the cursor on the first non-blank character on the line.ztLike z but leave the cursor in the same column.z.Redraw current line at the center of the window and put the cursor on the first non-blank character on the line.zzLike z....
Sometimes we want to design our own UI for "Sign In With Facebook" button instead of the original button that comes with FacebookSDK. In your storyboard, drag your UIButton and set it however you want it to be. Ctrl + drag your button to your view controller as IBAction. Inside the IB...
After the user signed in to Facebook at your app, now it's time to fetch the data you requested at the FBButton.readPermissions. Swift: enum FacebookParametesField : String { case FIELDS_KEY = "fields" case FIELDS_VALUE = "id, email, picture, first_name, last_name" ...
In SpriteKit a Sprite is represented by the SKSpriteNode class (which inherits from SKNode). First of all create a new Xcode Project based on the SpriteKit template as described in Your First SpriteKit Game. Creating a Sprite Now you can create a SKSpriteNode using an image loaded into the Assets...
Singly Linked Lists are a type of linked list. A singly linked list's nodes have only one "pointer" to another node, usually "next." It is called a singly linked list because each node only has a single "pointer" to another node. A singly linked list may have a head and...

Page 388 of 1336