ComputerScientist
174 subscribers
14 photos
3 files
206 links
▜ The Inventor

Stuff that inspire you to create.

See also: ▙ @LitMind
Download Telegram
#Geometry
Point in polygon
The point-in-polygon problem asks whether a given point in the plane lies inside, outside, or on the boundary of a polygon.

Ray casting algorithm
One simple way is to test how many times a ray, starting from the point and going in any fixed direction, intersects the edges of the polygon.

Even : outside
Odd : inside

⚠️ This method won't work if the point is on the edge of the polygon.

Most implementations of the ray casting algorithm consecutively check intersections of a ray with all sides of the polygon in turn.

A problem
If the ray passes exactly through a vertex of a polygon, then it will intersect 2 segments at their endpoints.

Solution: Count only if the second vertex of the side lies below the ray.
“Space games explode into a new dimension.”
— Zaxxon, the first #isometric game, 1982
Progress is dramatic.
#graphics #textures #3D
UV mapping
• Projecting a 2D texture onto a 3D model's surface.
• U and V denote the axes of the 2D texture.
• Unlike projection mapping, only maps into a screen space rather than into the geometric space of the object. But the rendering computation uses the UV texture coordinates to determine how to paint the three-dimensional surface.

Affine texture mapping
• Used by #GML.
• The cheapest algorithm to linearly interpolate texture coordinates across a surface.
• Does not take the depth of a vertices into account, therefore the polygon is not perspective correct.
• Works correctly for #isometric graphics.

Inverse-texture mapping
• Projects 3D vertices onto the screen during rendering and linearly interpolates the texture coordinates in screen space between them.
• Done by incrementing fixed point UV coordinates or by an incremental error algorithm akin to Bresenham's line algorithm.

Screen space
The coordinate space of the resulting 2D image during 3D rendering. The result of 3D projection on geometry in camera space.
Perspective correctness
#Nile
Guidelines
Whitespace means nothing.
World Creator v1.5 Freeware
Inet2Inet.com

Create your own stylised Textures.
Create Animation's.
Superimpose one texture on another.
Use Bump Maps.
Replace a selected range of colours with another.
Shade / Shadow effects.
Use 2 Texture Libraries and a Mask Library Simultaeneously
Create & Import user Tutorials (share files with other users).
Mix Solid Colours and Textures togetherCreate Cartoon or realistic style graphics.
Use the new Mask Packs now available.
Batch Textures (create hundreds of tiles with 1 mouse click).
Offset one Texture in relationship to another Texture.
Create your own Masks to suit your needs very simply.
Flip, Rotate, Tile Textures.
Create ISOMETRIC Tiles.
Create PSEUDO 3D Tiles.
Create 2D PLATFORM Tiles.
#Nile
Guidelines
Never have keywords.
#Nile
Guidelines
Formulate problems intuitively then recognize patterns.
Tokenizing
Breaking up the program into a list of strings that are independent tokens.
e.g. int a = 5[int] [a] [=] [5]

Lexing
Iterating over that list and converting the tokens into strong types.
e.g. [int] [a] [=] [5][type] [identifier] [assignment] [integerLiteral]
Parser is responsible for creating abstract syntax trees and logical validation of the code. The parser uses a stream of tokens.
“The beginning of wisdom is to call things by their proper name.”
— Chinese proverb
All data structures are trees. 🗃
Correctness
Correctness of an algorithm is asserted when it is said that the algorithm is correct with respect to a specification. Functional correctness refers to the input-output behaviour of the algorithm i.e., for each input it produces the expected output.

Partial versus Total correctness
An algorithm is partially correct if an answer is returned; it is totally correct if it terminates i.e., halts.

Halting problem
The problem of determining, from a description of an arbitrary computer program and an input, whether the program will finish running i.e., halt or continue to run forever.

#Alan_Turing proved in 1936 that a general algorithm to solve the halting problem for all possible program-input pairs cannot exist. A key part of the proof was a mathematical definition of a computer and program, which became known as a #Turing_machine; the halting problem is undecidable over Turing machines. It is one of the first examples of a decision problem.
Never go to sea with two chronometers;

take one or three.
#Java
Collections
It was designed to meet three goals:

• its implementations for the fundamental collections had to be highly efficient.
• it had to allow different types of collections to work in a similar manner and with interoperability.
• it had to adapt a new collection easily.

AbstractCollection: Implements most of the Collection interface.

Lists
AbstractList: Extends AbstractCollection and implements most of the List interface.
AbstractSequentialList: Extends AbstractList for use by a collection that uses sequential rather than random access of its elements.
LinkedList: Implements a linked list by extending AbstractSequentialList.
ArrayList: Implements a dynamic array by extending AbstractList.

Sets
AbstractSet: Extends AbstractCollection and implements most of the Set interface.
HashSet: Extends AbstractSet for use with a hash table.
LinkedHashSet: Extends HashSet to allow insertion-order iterations.
TreeSet: Implements a set stored in a tree. Extends AbstractSet.

Maps
AbstractMap: Implements most of the Map interface.
HashMap: Extends AbstractMap to use a hash table.
TreeMap: Extends AbstractMap to use a tree.
WeakHashMap: Extends AbstractMap to use a hash table with weak keys.
LinkedHashMap: Extends HashMap to allow insertion-order iterations.
IdentityHashMap: Extends AbstractMap and uses reference equality when comparing documents.
#Java
LinkedList

1. void add(int index, Object element)
Inserts the specified element at the specified position index in this list. Throws IndexOutOfBoundsException if the specified index is out of range (index < 0 || index > size()).

2. boolean add(Object o)
Appends the specified element to the end of this list.

3. boolean addAll(Collection c)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator. Throws NullPointerException if the specified collection is null.

4. boolean addAll(int index, Collection c)
Inserts all of the elements in the specified collection into this list, starting at the specified position. Throws NullPointerException if the specified collection is null.

5. void addFirst(Object o)
Inserts the given element at the beginning of this list.

6. void addLast(Object o)
Appends the given element to the end of this list.

7. void clear()
Removes all of the elements from this list.

8. Object clone()
Returns a shallow copy of this LinkedList.

9. boolean contains(Object o)
Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)).

10. Object get(int index)
Returns the element at the specified position in this list. Throws IndexOutOfBoundsException if the specified index is out of range (index < 0 || index >= size()).

11. Object getFirst()
Returns the first element in this list. Throws NoSuchElementException if this list is empty.

12. Object getLast()
Returns the last element in this list. Throws NoSuchElementException if this list is empty.

13. int indexOf(Object o)
Returns the index in this list of the first occurrence of the specified element, or -1 if the list does not contain this element.

14. int lastIndexOf(Object o)
Returns the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element.

15. ListIterator listIterator(int index)
Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list. Throws IndexOutOfBoundsException if the specified index is out of range (index < 0 || index >= size()).

16. Object remove(int index)
Removes the element at the specified position in this list. Throws NoSuchElementException if this list is empty.

17. boolean remove(Object o)
Removes the first occurrence of the specified element in this list. Throws NoSuchElementException if this list is empty. Throws IndexOutOfBoundsException if the specified index is out of range (index < 0 || index >= size()).

18. Object removeFirst()
Removes and returns the first element from this list. Throws NoSuchElementException if this list is empty.

19. Object removeLast()
Removes and returns the last element from this list. Throws NoSuchElementException if this list is empty.

20. Object set(int index, Object element)
Replaces the element at the specified position in this list with the specified element. Throws IndexOutOfBoundsException if the specified index is out of range (index < 0 || index >= size()).

21. int size()
Returns the number of elements in this list.

22. Object[] toArray()
Returns an array containing all of the elements in this list in the correct order. Throws NullPointerException if the specified array is null.

23. Object[] toArray(Object[] a)
Returns an array containing all of the elements in this list in the correct order; the runtime type of the returned array is that of the specified array.
Pattern matching
- is the act of checking a given sequence of tokens for the presence of the constituents of some pattern. In contrast to pattern recognition, the match has to either be or not be an exact match. The patterns have the form of either sequences or trees.

Sequence patterns, like strings, are often described using regular expressions and matched using techniques such as backtracking.

#regex
GoTo
- is a statement that performs a one-way transfer of control to another point of code; in contrast to a function call which returns control.

Its use has declined significantly since the advent of structured programming in the 1960s. Structured programming languages like #Pascal introduced control structures such as: subroutines, loops and multiway branch for clarity and efficiency. These replace equivalent flows written using gotos and ifs.

Language support:
#C
#CSharp: also makes case and default statements labels, whose scope is the enclosing switch statement; goto case or goto default is often used to replace explicit "fall-through", which C# disallows.
#Perl
#PHP there was no native support for goto until version 5.3
#Java: goto is a reserved word, but is unusable.
#Python: does not support it but there are several joke modules that provide it.

The structured program theorem proves that goto is not necessary to write programs.