Code Monkey home page Code Monkey logo

sklinearalgebra's Introduction

SKLinearAlgebra

Build Status

This library allows common vector operations using SceneKit's native types: SCNVector3, SCNVector4, and SCNMatrix4. It also provides useful linear algebra functions for 3D graphics.

It has been written in the style of Swift, intending to enhance and complete Scenekit's existing functions.

Features

Tests are complete for all implemented features.

Operations

  • equality (==)
  • inequality (!=)
  • equivalence (~=)
    • Returns true if the components are close to equal to each other.
  • inequivalence (!~=)
  • addition (+, +=)
  • subtraction (-, -=)
  • dot product (*)
  • scalar multiplication (*, *=)
  • scalar division (/, /=)
  • cross product (ร—)
  • subscript access (v[0], m[1, 2])
    • Zero based indexing
    • Access by [row, column]

Functions

  • cross product (cross(a: Vector, b: Vector))
  • magnitude (magnitude(v: Vector))
  • normalize (normalize(v: Vector))
  • angle between (angle(a: Vector, b: Vector))
  • component (component(a: Vector, b: Vector)) - comp_{b} a
    • Read this as "the component of a onto b", it would be written comp_{b} a.
  • projection (projection(a: Vector, b: Vector))
    • Read this as "the projection of a onto b", it would be written proj_{b} a
  • determinate (det(m: Matrix))
  • transpose (transpose(m: Matrix))
  • inverse (inverse(m: Matrix))

Usage

The documentation for using a custom Swift library is lacking at the moment, but my process has been as follows:

  1. Clone [email protected]:apexskier/SKLinearAlgebra.git into your project directory.
  2. Drag SKLinearAlgebra.xcodeproj into your Xcode project.
  3. Select your project, select your target, under General find "Linked Frameworks and Libraries".
  4. Add SKLinearAlgebra.framework, either from the + button or by dragging in SKLinearAlgebra/Products/SKLinearAlgebra.framework from the project navigator.
// Example import statements

import SceneKit
import SKLinearAlgebra

let vector = SCNVector4(x: 1, y: 2, z: 3, w: 4)
vector *= 4
println(vector)

Future Plans

  • Some kind of support for bases (origin + 3 vectors)
    • Conversion between basis
  • Use specific type aliases
    • Vectors for colors, locations, directions, rotations
  • Rotation utilities
  • Torque and Force utilities
  • Utilize Accelerate or Surge

You should follow me on Twitter.

sklinearalgebra's People

Contributors

apexskier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.