|
| 1 | +--- |
| 2 | +sidebar_position: 1 |
| 3 | +title: Introduction to Base Algorithms of Bitbybit |
| 4 | +sidebar_label: Base Algorithms of Bitbybit |
| 5 | +description: Discover the foundational capabilities of the @bitbybit-dev/base NPM package, your core toolkit for geometric and utility functions in Bitbybit. |
| 6 | +tags: [code, base] |
| 7 | +--- |
| 8 | + |
| 9 | +[View Package Source on GitHub](https://github.com/bitbybit-dev/bitbybit/tree/master/packages/dev/base) |
| 10 | +[NPM Package](https://www.npmjs.com/package/@bitbybit-dev/base) |
| 11 | + |
| 12 | +Welcome to the **`@bitbybit-dev/base`** package! This is the foundational layer of the Bitbybit ecosystem, providing a rich set of core utilities for mathematics, geometry, data manipulation, and more. Whether you're building complex 3D models, performing geometric analysis, or just need robust utility functions, the `base` package is your starting point. |
| 13 | + |
| 14 | +Think of this package as your essential toolbox, filled with well-defined, reliable tools that other Bitbybit functionalities and your own projects can build upon. |
| 15 | + |
| 16 | +## What's Inside? A Tour of Core Capabilities |
| 17 | + |
| 18 | +The `@bitbybit-dev/base` package is organized into several key classes, each specializing in a different area: |
| 19 | + |
| 20 | +### `Vector` - The Language of Position and Direction |
| 21 | + At its core, a vector (or a point) in Bitbybit is simply an array of numbers (e.g., `[x, y, z]`). The `Vector` class provides a comprehensive suite for: |
| 22 | + * **Creating** vectors and number sequences (like linear spans or eased distributions). |
| 23 | + * Performing fundamental **vector math**: addition, subtraction, dot product, cross product, scaling. |
| 24 | + * **Analyzing** vectors: calculating length (norm), normalizing (to get direction), finding distances, and measuring angles. |
| 25 | + * [Learn more about the Vector class...](./vector/intro) |
| 26 | + |
| 27 | +### `Point` - Defining Locations in Space |
| 28 | + While structurally similar to vectors, the `Point` class focuses on operations related to specific locations: |
| 29 | + * **Creating** individual points or patterned arrangements (like spirals or hexagonal grids). |
| 30 | + * **Transforming** points: moving (translating), rotating, and scaling them in 3D space. |
| 31 | + * **Analyzing** collections of points: finding the closest point, calculating bounding boxes, or determining the average position. |
| 32 | + * [Learn more about the Point class...](./point/intro) |
| 33 | + |
| 34 | +### `Line` - Working with Straight Segments |
| 35 | + The `Line` class deals with straight line segments defined by start and end points: |
| 36 | + * **Creating** lines from various inputs (pairs of points, sequences of points). |
| 37 | + * **Getting information** like length, endpoints, or points along the line. |
| 38 | + * **Transforming** lines and converting between different line/segment representations. |
| 39 | + * Performing **intersections** between lines. |
| 40 | + * [Learn more about the Line class...](./line/intro) |
| 41 | + |
| 42 | +### `Polyline` - Paths and Sequences of Lines |
| 43 | + Polylines are sequences of connected line segments, forming paths or outlines: |
| 44 | + * **Creating** polylines from lists of points, specifying if they are open or closed. |
| 45 | + * **Analyzing** polylines: calculating total length or getting their constituent points. |
| 46 | + * **Modifying** polylines: reversing direction or applying transformations. |
| 47 | + * Finding **intersections** (self-intersections or intersections between two polylines). |
| 48 | + * Advanced utilities like **sorting scattered segments** into continuous polylines. |
| 49 | + * [Learn more about the Polyline class...](./polyline/intro) |
| 50 | + |
| 51 | +### `Math` - Your Numerical Toolkit |
| 52 | + The `Math` class offers a wide array of numerical operations: |
| 53 | + * **Basic arithmetic** and standard mathematical functions (square root, absolute value, logarithms, trigonometry). |
| 54 | + * **Number generation** (random numbers, Pi). |
| 55 | + * **Number manipulation** like remapping values from one range to another. |
| 56 | + * Powerful **easing functions** for creating smooth, non-linear transitions and distributions. |
| 57 | + * [Learn more about the Math class...](./math/intro) |
| 58 | + |
| 59 | +### `Lists` - Managing Your Data Collections |
| 60 | + Lists (arrays) are fundamental for storing collections of data. The `Lists` class provides extensive tools for: |
| 61 | + * **Creating** and populating lists (e.g., repeating items). |
| 62 | + * **Accessing** items by index, getting sub-lists, or retrieving items based on patterns. |
| 63 | + * **Modifying** lists: adding, removing, or replacing items. |
| 64 | + * **Restructuring** lists: reversing, grouping, or transposing (flipping) 2D lists. |
| 65 | + * **Sorting** lists of numbers, text, or objects by property values. |
| 66 | + * [Learn more about the Lists class...](./lists/intro) |
| 67 | + |
| 68 | +### `Color` - Working with Colors |
| 69 | + The `Color` class helps you define, convert, and manipulate colors, primarily focusing on: |
| 70 | + * **Hexadecimal** (e.g., `#FF0000`) and **RGB** (Red, Green, Blue) color formats. |
| 71 | + * **Converting** seamlessly between these formats. |
| 72 | + * **Extracting** individual color components (R, G, B). |
| 73 | + * Performing basic manipulations like **inverting** a color. |
| 74 | + * [Learn more about the Color class...](./color/intro) |
| 75 | + |
| 76 | +### `Logic` - Making Decisions |
| 77 | + The `Logic` class is all about boolean values (`true`/`false`) and conditional operations: |
| 78 | + * **Creating** boolean values and lists of booleans (e.g., from random generation or by thresholding numerical data). |
| 79 | + * Performing **comparisons** between values (equal to, greater than, etc.). |
| 80 | + * Implementing **conditional logic** with "gates" that pass through data only if a condition is met. |
| 81 | + * [Learn more about the Logic class...](./logic/intro) |
| 82 | + |
| 83 | +### `Text` - Manipulating and Representing Text |
| 84 | + The `Text` class provides tools for string operations and an exciting feature for 3D: |
| 85 | + * Basic **string manipulation**: splitting, joining, replacing, and formatting text. |
| 86 | + * Converting various data types **to strings**. |
| 87 | + * Generating **vector text**: converting text characters into 2D vector paths, suitable for creating 3D text objects in your scenes. |
| 88 | + * [Learn more about the Text class...](./text/intro) <!-- Link to Text API page --> |
| 89 | + |
| 90 | +### `Dates` - Handling Date and Time |
| 91 | + The `Dates` class provides utilities for working with date and time information: |
| 92 | + * **Creating** `Date` objects (current time, specific dates, from timestamps). |
| 93 | + * **Converting** dates to various string formats (ISO, locale-specific, UTC). |
| 94 | + * **Getting and setting** individual components of a date (year, month, day, hour, etc.), with support for both local time and UTC. |
| 95 | + * **Parsing** date strings into `Date` objects. |
| 96 | + * [Learn more about the Dates class...](./dates/intro) <!-- Link to Dates API page --> |
| 97 | + |
| 98 | +### `Mesh Utilities` - Low-Level Mesh Operations |
| 99 | + The `MeshBitByBit` class offers specialized functions for working directly with mesh triangles and planes: |
| 100 | + * Calculating **distances to planes** and defining **triangle planes**. |
| 101 | + * Performing **intersections** between triangles and, by extension, between entire meshes to find intersection segments or polylines. |
| 102 | + * These are more advanced tools for detailed geometric analysis. |
| 103 | + * [Learn more about the Mesh Utilities class...](./mesh/intro) |
| 104 | + |
| 105 | +## Get Started! |
| 106 | + |
| 107 | +The `@bitbybit-dev/base` package is designed to be intuitive and powerful. Dive into the documentation for each class to explore their methods in detail and see how they can accelerate your development with Bitbybit. |
| 108 | + |
| 109 | +Happy coding! |
0 commit comments