-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
612a50f
commit e786a74
Showing
8 changed files
with
110 additions
and
4 deletions.
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "cg", | ||
"version": "0.1.0", | ||
"description" : "cg (computational geometry) algorithms templates for JavaScript", | ||
"homepage": "https://github.com/aureooms/cg", | ||
"moduleType": [ | ||
"node" | ||
], | ||
"license": "GPL v2" | ||
} |
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
var opt = { | ||
ns : 'cg', | ||
src : __dirname + '/src/', | ||
out : __dirname + '/dist/' | ||
}; | ||
|
||
|
||
|
||
// == GENERIC == | ||
|
||
var fs = require('fs'); | ||
var util = require('util'); | ||
var fmt = util.format; | ||
var recbuild_t = require('recbuild'); | ||
var UglifyJS = require("uglify-js"); | ||
|
||
|
||
var recbuild = recbuild_t({ | ||
name : opt.ns, | ||
rec : false, | ||
flat : true | ||
}); | ||
|
||
|
||
if (!fs.existsSync(opt.out)) fs.mkdirSync(opt.out); | ||
|
||
var fd, | ||
base = fmt('%s/%s%%s', opt.out, opt.ns), | ||
concat = fmt(base, '.js'), | ||
min = fmt(base, '.min.js'), | ||
map = fmt(base, '.js.map'); | ||
|
||
var fhandle = function(f) { | ||
var raw = fs.readFileSync(f); | ||
fs.writeSync(fd, raw.toString()); | ||
fs.writeSync(fd, '\n'); | ||
}; | ||
|
||
var rhandle = function(raw) { | ||
fs.writeSync(fd, raw); | ||
fs.writeSync(fd, '\n'); | ||
}; | ||
|
||
|
||
|
||
fd = fs.openSync(concat, 'w'); | ||
recbuild(opt.src, opt.ns, -1, fhandle, rhandle); | ||
fs.closeSync(fd); | ||
|
||
|
||
var minified = UglifyJS.minify(concat, { outSourceMap: map }); | ||
|
||
fs.writeFileSync(min, minified.code); | ||
fs.writeFileSync(map, minified.map); |
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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
(function(exports){ | ||
|
||
'use strict'; | ||
|
||
|
||
/* /home/genius/Bureau/cg/js/src/2d */ | ||
/* /home/genius/Bureau/cg/js/src/2d/sin_sign.js */ | ||
|
||
/** | ||
* Computes the cross product of _ab_ and _ac_, | ||
* can be interpreted as the sinus sign in a "right-handed" coordinate system | ||
* (i.e. clockwise angle values). | ||
* | ||
* <p> | ||
* Originally implemented as | ||
* | ||
* a[1] * (c[0] - b[0]) + b[1] * (a[0] - c[0]) + c[1] * (b[0] - a[0]) | ||
* | ||
* with | ||
* - 2 add | ||
* - 3 sub | ||
* - 3 mul | ||
* | ||
* Reduced to | ||
* | ||
* (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]) | ||
* | ||
* with | ||
* - 5 sub | ||
* - 2 mul | ||
* | ||
*/ | ||
|
||
var sin_sign = function(a, b, c){ | ||
return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); | ||
}; | ||
|
||
|
||
exports.sin_sign = sin_sign; | ||
})(typeof exports === 'undefined' ? this['cg'] = {} : exports); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 characters