Posts

Robotics

Here’s a basic JavaScript code snippet demonstrating the three primary trigonometric functions (sin, cos, tan) along with some additional functions like asin, acos, and atan: <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">   <meta name="viewport" content="width=device-width, initial-scale=1.0">   <title>Trigonometric Functions</title> </head> <body>   <h1>Trigonometric Functions in JavaScript</h1>   <p>Check the console for the results.</p>   <script>     // Angle in degrees     let angleInDegrees = 30;     // Convert angle to radians     let angleInRadians = angleInDegrees * (Math.PI / 180);     // Trigonometric calculations     let sineValue = Math.sin(angleInRadians);     let cosineValue = Math.cos(angleInRadians);     let tangentValue = Math.tan(angleInRadians);    ...

Drone

const drone = document.getElementById("drone"); let x = 135; let y = 135; document.addEventListener("keydown", (event) => {   const step = 5; // Movement step size   switch (event.key) {     case "ArrowUp": // Move up       if (y - step >= 0) y -= step;       break;     case "ArrowDown": // Move down       if (y + step <= 270) y += step;       break;     case "ArrowLeft": // Move left       if (x - step >= 0) x -= step;       break;     case "ArrowRight": // Move right       if (x + step <= 270) x += step;       break;     default:       break;   }   // Update drone position   drone.style.top = `${y}px`;   drone.style.left = `${x}px`; });

Space engineering

#include <Servo.h> // Create servo objects Servo finServo1; Servo finServo2; Servo finServo3; // Pin configuration const int fin1Pin = 9; const int fin2Pin = 10; const int fin3Pin = 11; // Angle variables int angle1 = 90;  // Initial angle for stabilization int angle2 = 90; int angle3 = 90; // Function to adjust fins (simulate stabilization) void adjustFins(int angle1, int angle2, int angle3) {   finServo1.write(angle1);   finServo2.write(angle2);   finServo3.write(angle3); } void setup() {   // Attach servos to pins   finServo1.attach(fin1Pin);   finServo2.attach(fin2Pin);   finServo3.attach(fin3Pin);     // Initial position   adjustFins(angle1, angle2, angle3); } void loop() {   // Example: Adjusting fin angles based on arbitrary conditions   angle1 = random(80, 100);  // Simulate dynamic stabilization   angle2 = random(80, 100);   angle3 = random(80, 100);   ...

Self driving cars

Pak Army FanPage Muslim World League - رابطة العالم الإسلامي 𝐒𝐞𝐥𝐟 𝐝𝐫𝐢𝐯𝐢𝐧𝐠 𝐜𝐚𝐫𝐬 import cv2 import numpy as np def region_of_interest(img, vertices):     mask = np.zeros_like(img)     cv2.fillPoly(mask, vertices, 255)     masked_image = cv2.bitwise_and(img, mask)     return masked_image def draw_lines(img, lines):     for line in lines:         x1, y1, x2, y2 = line[0]         cv2.line(img, (x1, y1), (x2, y2), (255, 0, 0), 10) def process_frame(frame):     height, width = frame.shape[:2]     region_vertices = [(0, height), (width // 2, height // 2), (width, height)]     gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)     blur = cv2.GaussianBlur(gray, (5, 5), 0)     edges = cv2.Canny(blur, 50, 150)     cropped_edges = region...
Image
Open in app Sign up Sign in   class Car { constructor (x,y,width,height,controlType,maxSpeed= 3 ){ this .x=x; this .y=y; this .width=width; this .height=height; this .speed= 0 ; this .acceleration= 0.2 ; this .maxSpeed=maxSpeed; this .friction= 0.05 ; this .angle= 0 ; this .damaged= false ; this .useBrain=controlType== "AI" ; if (controlType!= "DUMMY" ){ this .sensor=new Sensor(); this .brain=new NeuralNetwork( [ this .sensor.rayCount, 4 ] ); } this .controls=new Controls(controlType); } update(roadBorders,traffic){ if (! this .damaged){ this .#move(); this .polygon= this .#createPolygon(); this .damaged= this .#assessDamage(roadBorders,traffic); } if ( this .sensor){ this .sensor.update( this .x, this .y, this .angle,roadBorders,traffic); ...

Full stack

Database: Update the MONGODB_URI in your .env file with the production database credentials. Verify and adjust the database name, host, and any additional connection options (e.g., replica sets, connection pool settings). Backend: Change the CORS origin from http://localhost:5173 to your deployed front-end URL. Adjust middleware or static file paths if your production directory structure differs. Update API route configurations if there are any changes in the endpoints or business logic. Modify error handling (e.g., reducing detailed error output) to suit a production environment. Change the server port (via process.env.PORT or hardcoded) if necessary for your deployment. Front End: Update the API base URL in your front-end configuration to point to your production backend. Replace any hardcoded local URLs (like http://localhost:5173 ) with the production URL. Ensure that any environment-specific settings (e.g., API endpoints, port numbers) are correctly set for the...

How to live a life

Mohtat ho k chalna