[![view on npm](http://img.shields.io/npm/v/jscad-gears.svg)](https://www.npmjs.org/package/jscad-gears) [![npm module
downloads](http://img.shields.io/npm/dt/jscad-gears.svg)](https://www.npmjs.org/package/jscad-gears)

# jscad-gears

![gear example](jsdoc2md/jscad-gears.png)

This is a collection of jscad parts that model a RaspberryPi BPlus and various Hats. These models use the
[jscad-utils](https://github.com/johnwebbcole/jscad-utils) library and return jscad-utils [`group`
objects](https://github.com/johnwebbcole/jscad-utils#utilgroupnames-objects--object).


## Installation
Install `jscad-gears` using NPM:

```bash
npm install --save jscad-gears jscad-utils
```

## Basic usage
To use the gears package, you need to include the `jscad-gears.jscad` file and `jscad-utils.jscad`.

```javascript
include('node_modules/jscad-utils/jscad-utils.jscad');
include('node_modules/jscad-gears/jscad-gears.jscad');
include('node_modules/lodash/lodash.js');

main() {
util.init(CSG);

var qualitySettings = {
resolution: CSG.defaultResolution2D,
stepsPerToothAngle: 3
};
var wheel = { id: 78.5, od: 104.1, h: 22 };

var toothCount = 64;

var g = new Gear({
toothCount,
circularPitch: (Math.PI * (wheel.id + 4)) / toothCount,
toothCount: toothCount,
qualitySettings: qualitySettings
});

var shape = g.getZeroedShape();
return util.poly2solid(shape, shape, 15);
}
```

## Yeoman Generator
You can use the [yeoman jscad generator](https://www.npmjs.com/package/generator-jscad) which will create a project
that uses this library.

Once you create your project, install `jscad-gears`, and run `gulp`. Dragging the `dist` directory into
[http://openjscad.org/](http://openjscad.org/) will include this library.

Modify your `main.jscad` file to return a RaspberryPi object.

```javascript
// include:js
// endinject
/* exported main, getParameterDefinitions */
/* globals piexample */


function main(params) {

util.init(CSG);

var qualitySettings = {
resolution: CSG.defaultResolution2D,
stepsPerToothAngle: 3
};
var wheel = { id: 78.5, od: 104.1, h: 22 };

var toothCount = 64;

var g = new Gear({
toothCount,
circularPitch: (Math.PI * (wheel.id + 4)) / toothCount,
toothCount: toothCount,
qualitySettings: qualitySettings
});

var shape = g.getZeroedShape();
return util.poly2solid(shape, shape, 15);
}
```

## Reference

### Gears
{{#module name="jscad-gears"}}
{{>body~}}
{{>member-index~}}
{{>members~}}
{{/module}}

&copy; 2016 John Cole <johnwebbcole@gmail.com>. Documented by
  [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown).