Last active
November 17, 2021 18:56
Revisions
-
codelynx revised this gist
Nov 6, 2015 . No changes.There are no files selected for viewing
-
codelynx created this gist
Nov 6, 2015 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ // // simd+ext.swift // // Created by Kaz Yoshikawa on 11/6/15. // // import Foundation import simd import GLKit extension float4x4 { static func makeScale(x: Float, _ y: Float, _ z: Float) -> float4x4 { return unsafeBitCast(GLKMatrix4MakeScale(x, y, z), float4x4.self) } static func makeRotate(radians: Float, _ x: Float, _ y: Float, _ z: Float) -> float4x4 { return unsafeBitCast(GLKMatrix4MakeRotation(radians, x, y, z), float4x4.self) } static func makeTranslation(x: Float, _ y: Float, _ z: Float) -> float4x4 { return unsafeBitCast(GLKMatrix4MakeTranslation(x, y, z), float4x4.self) } static func makePerspective(fovyRadians: Float, _ aspect: Float, _ nearZ: Float, _ farZ: Float) -> float4x4 { return unsafeBitCast(GLKMatrix4MakePerspective(fovyRadians, aspect, nearZ, farZ), float4x4.self) } static func makeFrustum(left: Float, _ right: Float, _ bottom: Float, _ top: Float, _ nearZ: Float, _ farZ: Float) -> float4x4 { return unsafeBitCast(GLKMatrix4MakeFrustum(left, right, bottom, top, nearZ, farZ), float4x4.self) } static func makeOrtho(left: Float, _ right: Float, _ bottom: Float, _ top: Float, _ nearZ: Float, _ farZ: Float) -> float4x4 { return unsafeBitCast(GLKMatrix4MakeOrtho(left, right, bottom, top, nearZ, farZ), float4x4.self) } static func makeLookAt(eyeX: Float, _ eyeY: Float, _ eyeZ: Float, _ centerX: Float, _ centerY: Float, _ centerZ: Float, _ upX: Float, _ upY: Float, _ upZ: Float) -> float4x4 { return unsafeBitCast(GLKMatrix4MakeLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ), float4x4.self) } func scale(x: Float, y: Float, z: Float) -> float4x4 { return self * float4x4.makeScale(x, y, z) } func rotate(radians: Float, _ x: Float, _ y: Float, _ z: Float) -> float4x4 { return self * float4x4.makeRotate(radians, x, y, z) } func translate(x: Float, _ y: Float, _ z: Float) -> float4x4 { return self * float4x4.makeTranslation(x, y, z) } }